behat/common-contexts
Abandoned Behat 2.x add-on providing reusable subcontexts with extra steps/hooks. Includes contexts like SymfonyMailerContext, DoctrineFixturesContext, and SymfonyDoctrineContext for loading fixtures, purging DB, and resetting schema in Symfony-based suites.
ContainerInterface (e.g., $this->kernel->getContainer()), which Laravel replaces with its own container or no DI in tests.useContext(), getSubcontext()) is deprecated in Behat 3.x+ and lacks Laravel integration (e.g., no create() or assertDatabaseHas() compatibility).SymfonyMailerContext targets Symfony 2.x’s SwiftmailerBundle, whereas Laravel uses its Mail facade (Mail::fake() for testing).DatabaseSeeder, Factory classes, or packages like orchestra/testbench for Doctrine.SymfonyMailerContext with Mail::fake() or spatie/laravel-mail-trap.Artisan::call('migrate:fresh'), DatabaseMigrations, or sail for Docker-based resets.laravel-shift/database-seeder, fakerphp/faker.Mail::fake(), spatie/laravel-mail-trap.php artisan migrate:fresh --seed.behat/behat:^3.0.app() or Behat 3.x’s service injection.ORMPurger, ORMExecutor with Eloquent/DBAL equivalents (e.g., Schema::dropAllTables(), Factory::new()).SymfonyMailerContext with a context using Mail::fake().php artisan test).// laravel-common-contexts/src/LaravelMailContext.php
use Behat\Testwork\Hook\Scope\ScenarioScope;
use Illuminate\Support\Facades\Mail;
class LaravelMailContext implements Context
{
public function __construct(private ScenarioScope $scope) {}
/**
* @Given I have sent an email to :email
*/
public function iHaveSentAnEmail(string $email): void
{
Mail::fake();
Mail::to($email)->send(new TestMail());
Mail::assertSent(TestMail::class);
}
}
behat/behat:2.x in a composer.json scoped to the Symfony module).| Component | Laravel Compatibility | Workaround |
|---|---|---|
| Behat 2.x Contexts | ❌ No | Fork + rewrite for Behat 3.x |
| SymfonyMailerContext | ❌ No (Swiftmailer) | Use Mail::fake() |
| DoctrineFixturesContext | ⚠️ Partial (ORM v2) | Use Eloquent Factories or Testbench |
| SymfonyDoctrineContext | ❌ No (Symfony DI) | Artisan::call('migrate:fresh') |
Mail::fake()).DatabaseSeeder or Factory.SymfonyDoctrineContext with Artisan::call('migrate:fresh')").Mail::fake() is updated by Laravel core team).| Failure Scenario | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Behat 2.x Deprecation | High |
How can I help you explore Laravel packages today?