graham-campbell/testbench
Laravel TestBench adds testing helpers for Laravel packages and apps, built on PHPUnit, Mockery, and Orchestral Testbench. Supports Laravel 8–13 and PHP 7.4–8.5, providing a solid base for fast, reliable package tests.
Strengths:
AbstractTestCase, AbstractPackageTestCase) allow for easy extension without requiring custom configuration or service provider registration.Weaknesses:
getBasePath and getRequiredServiceProviders becoming static) may require updates to existing test suites.composer require installation with no manual configuration, reducing integration risk.Testing strategy alignment:
Laravel/PHP version constraints:
Customization needs:
CI/CD and performance:
Maintenance and support:
Team adoption:
.env.testing) are loaded and applied as expected.RefreshDatabase or MigrateFresh traits for database-backed tests.Assessment phase:
Installation:
composer.json as a dev dependency:
composer require --dev graham-campbell/testbench:^6.3
Incremental adoption:
AbstractPackageTestCase.
Example:
use GrahamCampbell\TestBench\AbstractPackageTestCase;
class MyServiceProviderTest extends AbstractPackageTestCase
{
protected function getPackageProviders($app)
{
return ['App\Providers\MyServiceProvider'];
}
public function test_service_provider_registers_bindings()
{
$this->assertTrue($this->app->bound('my-binding'));
}
}
AbstractTestCase for middleware, routes, or custom logic.
Example:
use GrahamCampbell\TestBench\AbstractTestCase;
class MyMiddlewareTest extends AbstractTestCase
{
public function test_middleware_adds_header()
{
$response = $this->get('/test');
$response->assertHeader('X-Custom-Header', 'value');
}
}
Legacy migration:
getBasePath()).kylekatarnls/update-helper package to avoid invasive updates.composer why-not graham-campbell/testbench.phpunit.xml.Http\TestResponse) are compatible with TestBench.How can I help you explore Laravel packages today?