Loading...
Loading...
Tests applications using the Pest 3 PHP framework in Bagisto. Activates when writing tests, creating unit or feature tests, adding assertions, testing Livewire components, architecture testing, debugging test failures, working with datasets or mocking; or when the user mentions test, spec, TDD, expects, assertion, coverage, or needs to verify functionality works.
npx skill4agent add bagisto/agent-skills pest-testingpackages/Webkul/{Package}/tests/packages/Webkul/
├── Admin/
│ └── tests/
│ ├── AdminTestCase.php # Base test case
│ ├── Concerns/
│ │ └── AdminTestBench.php # Test helpers
│ └── Feature/
│ ├── ExampleTest.php
│ └── ...
├── Shop/
│ └── tests/
│ ├── ShopTestCase.php
│ ├── Concerns/
│ │ └── ShopTestBench.php
│ └── Feature/
│ ├── Checkout/
│ │ └── CheckoutTest.php
│ └── ...
├── Core/
│ └── tests/
│ ├── CoreTestCase.php
│ ├── Concerns/
│ │ └── CoreAssertions.php
│ ├── Unit/
│ └── Feature/
├── DataGrid/
│ └── tests/
│ ├── DataGridTestCase.php
│ └── Unit/
└── Installer/
└── tests/
├── InstallerTestCase.php
└── Feature/phpunit.xml| Test Suite | Location | Command |
|---|---|---|
| Admin Feature Test | | |
| Core Unit Test | | |
| DataGrid Unit Test | | |
| Installer Feature Test | | |
| Shop Feature Test | | |
tests/Pest.php<?php
uses(Webkul\Admin\Tests\AdminTestCase::class)->in('../packages/Webkul/Admin/tests');
uses(Webkul\Core\Tests\CoreTestCase::class)->in('../packages/Webkul/Core/tests');
uses(Webkul\DataGrid\Tests\DataGridTestCase::class)->in('../packages/Webkul/DataGrid/tests');
uses(Webkul\Installer\Tests\InstallerTestCase::class)->in('../packages/Webkul/Installer/tests');
uses(Webkul\Shop\Tests\ShopTestCase::class)->in('../packages/Webkul/Shop/tests');Tests\TestCase// packages/Webkul/Shop/tests/ShopTestCase.php
<?php
namespace Webkul\Shop\Tests;
use Tests\TestCase;
use Webkul\Core\Tests\Concerns\CoreAssertions;
use Webkul\Shop\Tests\Concerns\ShopTestBench;
class ShopTestCase extends TestCase
{
use CoreAssertions, ShopTestBench;
}composer.json"autoload": {
"psr-4": {
"Webkul\\Admin\\": "packages/Webkul/Admin/src",
"Webkul\\Shop\\": "packages/Webkul/Shop/src",
"Webkul\\Core\\": "packages/Webkul/Core/src",
...
}
}autoload-dev"autoload-dev": {
"psr-4": {
"Tests\\": "tests/",
"Webkul\\Admin\\Tests\\": "packages/Webkul/Admin/tests",
"Webkul\\Core\\Tests\\": "packages/Webkul/Core/tests",
"Webkul\\DataGrid\\Tests\\": "packages/Webkul/DataGrid/tests",
"Webkul\\Installer\\Tests\\": "packages/Webkul/Installer/tests",
"Webkul\\Shop\\Tests\\": "packages/Webkul/Shop/tests"
}
}php artisan test --compactphp artisan test --testsuite="Shop Feature Test"
php artisan test --testsuite="Admin Feature Test"
php artisan test --testsuite="Core Unit Test"php artisan test --compact packages/Webkul/Shop/tests/Feature/Checkout/CheckoutTest.phpphp artisan test --compact --filter=testName# Shop tests
php artisan test --compact packages/Webkul/Shop/tests/
# Admin tests
php artisan test --compact packages/Webkul/Admin/tests/
# Core tests
php artisan test --compact packages/Webkul/Core/tests/php artisan make:test --pest packages/Webkul/Shop/tests/Feature/Checkout/MyNewTestphp artisan make:test --pest --unit packages/Webkul/Core/tests/Unit/MyNewTest<?php
namespace Webkul\Shop\Tests\Feature\Checkout;
use Webkul\Shop\Tests\ShopTestCase;
it('should pass basic test', function () {
expect(true)->toBeTrue();
});
it('should return successful response', function () {
$response = $this->getJson('/api/categories');
$response->assertStatus(200);
});assertSuccessful()assertNotFound()assertStatus()| Use | Instead of |
|---|---|
| |
| |
| |
use function Pest\Laravel\mock;it('has valid emails', function (string $email) {
expect($email)->not->toBeEmpty();
})->with([
'james' => 'james@bagisto.com',
'john' => 'john@bagisto.com',
]);arch('controllers')
->expect('Webkul\Admin\Http\Controllers')
->toExtendNothing()
->toHaveSuffix('Controller');
arch('models')
->expect('Webkul\Core\Models')
->toExtend('Illuminate\Database\Eloquent\Model');
arch('no debugging')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();uses(Webkul\NewPackage\Tests\NewPackageTestCase::class)->in('../packages/Webkul/NewPackage/tests');"autoload-dev": {
"psr-4": {
"Webkul\\NewPackage\\Tests\\": "packages/Webkul/NewPackage/tests"
}
}<testsuite name="New Package Test">
<directory suffix="Test.php">packages/Webkul/NewPackage/tests</directory>
</testsuite>composer dump-autoloaduse function Pest\Laravel\mock;assertStatus(200)assertSuccessful()composer dump-autoloadtests/Pest.phpphpunit.xml$this->fakerfake()