Testing Messaging
Testing Messaging architecture in PHP
Ecotone Lite
Configuring Ecotone Lite for your tests
$ecotoneLite = EcotoneLite::bootstrapFlowTesting(
// 1. Classes to resolve - specify which classes contain Ecotone attributes
[User::class],
// 2. Available services - provide service instances or inject a container
[new EmailConverter(), new PhoneNumberConverter(), new UuidConverter()],
// 3. Service Configuration - customize the test environment
ServiceConfiguration::createWithDefaults()
// 4. Load classes from specific namespaces automatically
->withNamespaces(["App\Testing\Infrastructure\Converter"])
// 5. Add extension objects for additional functionality
->withExtensionObjects([
// 6. Use in-memory repositories for fast testing
InMemoryStateStoredRepositoryBuilder::createForAllAggregates()
])
// 7. Disable modules not needed for this test
->withSkippedModulePackageNames([
// 8. Skip async processing to run tests synchronously
ModulePackageList::ASYNCHRONOUS_PACKAGE
])
);Testing Command Handlers
Calling Event Bus
Verifying Published Events
Verifying Message Headers
Verifying Commands/Queries
Discarding recorded messages
Caching Configuration
Common Pitfalls and Troubleshooting
Missing Dependencies in Test Setup
Asynchronous Code Not Working in Tests
Events Not Being Recorded
Class Not Found Errors
Last updated
Was this helpful?