Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Pest Plugin for Testbench

Pest Plugin for Testbench is a small packages to use PestPHP for Laravel Packages.

Tests Latest Stable Version Total Downloads Latest Unstable Version License

Installation

Install the package with Composer:

composer require --dev orchestra/pest-plugin-testbench

Pest Compatibility

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

Usage

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');

defineEnvironment()

use Illuminate\Foundation\Application;

use function Orchestra\Testbench\Pest\defineEnvironment;

defineEnvironment(function (Application $app) {
    $app['config']->set('example.enabled', true);
});

defineRoutes()

use function Orchestra\Testbench\Pest\defineRoutes;

defineRoutes(function ($router) {
    $router->get('/hello', fn () => 'Hello World');
});

Example test

it('can define the package environment and routes', function () {
    expect(config('example.enabled'))->toBeTrue();

    $this->get('/hello')
        ->assertOk()
        ->assertSee('Hello World');
});

setUp()

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);
});

defineDatabaseMigrations()

use function Orchestra\Testbench\Pest\defineDatabaseMigrations;

defineDatabaseMigrations(function () {
    $this->artisan('migrate', [
        '--path' => \Orchestra\Testbench\package_path('database/migrations'),
    ]);
});

defineDatabaseSeeders()

use function Orchestra\Testbench\Pest\defineDatabaseSeeders;

defineDatabaseSeeders(function () {
    $this->seed(\Database\Seeders\ExampleSeeder::class);
});

Contributing

Thank you for considering contributing to Workbench! You can read the contribution guide here.

Code of Conduct

In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.

License

Workbench is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages