Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Behat Orm Context

Behat Orm Context Laravel Package

macpaw/behat-orm-context

Behat ORM Context by MacPaw provides Doctrine ORM-aware Behat contexts for acceptance testing in PHP projects. It helps manage entities, fixtures, and database state, keeping scenarios isolated and readable while reducing boilerplate around test data setup and cleanup.

View on GitHub
Deep Wiki
Context7

Behat Context for testing Symfony ORM

Frequently asked questions about Behat Orm Context
Does macpaw/behat-orm-context work with Laravel?
Only conditionally. The package is a Symfony bundle built around Doctrine ORM and Behat, so it does nothing for a standard Eloquent-only Laravel app. It becomes usable when your Laravel service already runs Doctrine ORM, for example through laravel-doctrine, and you have a real Gherkin acceptance-test requirement.
How do I install macpaw/behat-orm-context?
Install it as a dev dependency with composer require --dev macpaw/behat-orm-context. You also need Behat 3 and Doctrine ORM 2 or 3 in the same project, plus PHP 8.1 or newer. Because v2 supports Symfony 6.4 through 8, it should resolve against the Symfony components shipped with Laravel 10, 11, and 12. If resolution fails, run composer why-not symfony/framework-bundle to find what is pinning an older version.
Can I use Behat ORM Context without Doctrine ORM?
No. The contexts are Doctrine-aware and need an EntityManager to manage entities, reset database state, and load fixtures. If your app is Eloquent-only, there is no useful behavior here. Use Laravel's RefreshDatabase trait with Pest or PHPUnit instead.
Which Laravel and Symfony versions does Behat ORM Context support?
Version 2.0 requires PHP 8.1 or newer, Symfony 6.4 through 8, Doctrine ORM 2 or 3, and Behat 3. That range covers the Symfony floors used by Laravel 10, 11, and 12, which is the main compatibility change in v2.0.0. Symfony below 6.4 is no longer supported, so verify no other dependency pins an older release.
How does Behat ORM Context clean the database between scenarios?
It provides hooks that reset ORM state between scenarios so each one starts from a known baseline, keeping tests isolated and repeatable. The exact strategy depends on which context you enable and how you configure it. In a Laravel project, confirm the reset uses your test database connection and never touches development or production data.
How do I load fixtures with macpaw/behat-orm-context?
Fixture loading and shared test-data setup are part of the package's context features. You register the context in behat.yml and point it at the fixture paths or loaders it should use. In a Laravel app you would typically target Doctrine fixtures rather than Eloquent seeders, since the context resolves entities through the EntityManager.
Does Behat ORM Context integrate with laravel-doctrine?
Not out of the box; there is no Laravel service provider or auto-wiring, because the package follows the Symfony bundle model. You wire the context manually in behat.yml and give it access to the EntityManager that laravel-doctrine configures. Expect a small bootstrap so Behat can reach your application container and manager, and validate it on a scoped spike before committing.
Can I use Behat ORM Context alongside Pest or PHPUnit?
Technically yes, but it adds a second BDD layer rather than replacing anything. The package is dev-only and its contexts run inside Behat scenarios, so Pest and PHPUnit keep their existing role. Add it in an isolated suite such as tests/behat only if you have a QA-owned Gherkin requirement that Pest datasets and describe blocks do not cover.
Is macpaw/behat-orm-context production-ready and well maintained?
It is a dev-only testing tool, so it never ships to production. Maintenance signals are mixed: strong static analysis, PSR-12 and Rector tooling on one side, but a small repository with a single-vendor origin and no documented security disclosure policy on the other. Treat release provenance as unverified until you check the tag and commit signing, and assume you may have to fix issues yourself.
What are the alternatives to Behat ORM Context for Laravel testing?
For Eloquent apps, Pest with RefreshDatabase, model factories, and seeders covers most acceptance-testing needs. If you specifically need Gherkin, Behat plus your own Doctrine contexts is the closest substitute. For Doctrine fixture handling, DoctrineFixturesBundle and the Alice library are the common choices.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo