Pest Plugin for Testbench is a small packages to use PestPHP for Laravel Packages.
Install the package with Composer:
composer require --dev orchestra/pest-plugin-testbench| Pest | PHP | Testbench |
|---|---|---|
| 5.x | 8.4+ | 11.x |
| 4.x | 8.2+ | 10.x |
| 3.x | 8.2+ | 9.x |
| 2.x | 8.1+ | 8.x |
Create a Testbench test case and bind it to your Pest test files:
// tests/TestCase.php
namespace Tests;
class TestCase extends \Orchestra\Testbench\TestCase
{
//
}// tests/Pest.php
uses(Tests\TestCase::class)->in('Feature');use Illuminate\Foundation\Application;
use function Orchestra\Testbench\Pest\defineEnvironment;
defineEnvironment(function (Application $app) {
$app['config']->set('example.enabled', true);
});use function Orchestra\Testbench\Pest\defineRoutes;
defineRoutes(function ($router) {
$router->get('/hello', fn () => 'Hello World');
});it('can define the package environment and routes', function () {
expect(config('example.enabled'))->toBeTrue();
$this->get('/hello')
->assertOk()
->assertSee('Hello World');
});Call the provided $parent closure to preserve Testbench's default per-test setup:
use function Orchestra\Testbench\Pest\setUp;
setUp(function ($parent) {
$parent();
$this->app['config']->set('example.enabled', true);
});use function Orchestra\Testbench\Pest\defineDatabaseMigrations;
defineDatabaseMigrations(function () {
$this->artisan('migrate', [
'--path' => \Orchestra\Testbench\package_path('database/migrations'),
]);
});use function Orchestra\Testbench\Pest\defineDatabaseSeeders;
defineDatabaseSeeders(function () {
$this->seed(\Database\Seeders\ExampleSeeder::class);
});Thank you for considering contributing to Workbench! You can read the contribution guide here.
In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.
Workbench is open-sourced software licensed under the MIT license.