- What does macpaw/behat-messenger-context do?
- It is a Behat context for Symfony Messenger that lets BDD scenarios assert messages were dispatched, handled, or routed to specific transports. It also lets steps inspect the message envelope so async messaging behavior is visible in Gherkin. It is intended for PHP teams already using Behat and Symfony Messenger, not as a Laravel-native testing tool.
- Can I use macpaw/behat-messenger-context in a Laravel application?
- Not as a drop-in Laravel package. Laravel uses Illuminate\Bus and its own queue implementation, while this context inspects Symfony Messenger's bus, envelopes, and transports. You would have to bootstrap Behat and bind Symfony Messenger as a second bus in the Laravel container, which adds confusion and risks false-green tests. For normal Laravel coverage, use Bus::fake(), Queue::fake(), and Event::fake().
- How do I install and configure macpaw/behat-messenger-context?
- Install it as a development dependency with Composer using composer require --dev macpaw/behat-messenger-context. Then register the package's context classes in your behat.yml and make sure the Behat bootstrap starts Symfony Messenger with the transports you want to assert against. Keep it in require-dev because it is test tooling, not production runtime code.
- Does it support Laravel's Bus::fake or Queue::fake assertions?
- No. The package targets Symfony Messenger's Envelope, bus, and transport APIs, not Laravel's Bus or Queue fakes. The assertion ideas are similar—dispatched counts, handled messages, and routing—but the implementations are not interchangeable. In Laravel, use assertDispatched, assertPushed, and assertNothingDispatched with Bus::fake() or Queue::fake().
- Do I need Symfony Messenger to use this package?
- Yes. The application under test must dispatch messages through Symfony Messenger because the context asserts against Messenger's message bus, envelopes, stamps, and transports. Behat alone is not enough; Messenger must be configured and bound in the test environment. If your code only uses Laravel's dispatcher, this package has no Messenger activity to inspect.
- Does macpaw/behat-messenger-context support Laravel 10 and Laravel 11?
- There is no Laravel version matrix for this package because it does not integrate with Laravel's bus. Its compatibility depends on your Behat and Symfony Messenger versions, and Laravel's own symfony/* Composer constraints can conflict when you add Messenger alongside it. Treat any Laravel 10 or Laravel 11 use as a custom integration you must validate, not a supported path.
- Which Symfony Messenger transports can it assert against?
- The context works with Symfony Messenger transports configured in your Messenger setup, such as in-memory or async transports, because assertions are scoped to Messenger transport behavior. The v3.1.0 queue reset hook helps with state between scenarios, but its reset semantics are transport-scoped. Validate it against each transport you use, especially async transports such as Doctrine or AMQP, and remember it does not reset Laravel's queue state.
- What changed in v3.1.0 of macpaw/behat-messenger-context?
- v3.1.0 is a minor, non-breaking release over v3.0.1 that adds a hook to reset message queues before each scenario. This directly mitigates the prior risk of messages leaking between scenarios and producing order-dependent results. It does not reconcile Symfony Messenger state with Laravel's queue state or solve the dual-bus problem.
- Is macpaw/behat-messenger-context actively maintained and safe to adopt?
- It is a small, MIT-licensed, single-vendor package from MacPaw with limited community validation, low stars, and no dependents noted in the evaluation. v3.1.0 added two first-time contributors, which is a marginal positive signal for activity and bus factor, but governance and roadmap remain vendor-controlled. Because the surface area is thin, it is relatively cheap to vendor or fork if upstream stalls.
- What are alternatives to this package for testing dispatched messages in Laravel?
- For Laravel, the native alternatives are Bus::fake(), Queue::fake(), and Event::fake() with assertions such as assertDispatched, assertPushed, and assertNothingDispatched. Laravel's fakes are re-instantiated per test method, so you get scenario isolation without adding Behat or Symfony Messenger. If Behat is mandatory, write a thin custom context over Laravel's fakes instead of installing this package.