morebec / orkestra-event-sourcing-testing
Orkestra component with utilities for easily testing event sourced systems based on Orkestra and Symfony
v2.5.6
2023-03-31 18:46 UTC
Requires
- php: >=7.4
- coduo/php-matcher: 6.0.*
- morebec/orkestra-event-sourcing: ^2.5.6
- phpunit/phpunit: ^9.5
- ramsey/uuid: ^4.1
- symfony/framework-bundle: 5.2.*
Requires (Dev)
- ext-dom: *
- coduo/php-matcher: ^6.0
- friendsofphp/php-cs-fixer: ^2.16
- phpstan/phpstan: ^0.12.7
- symfony/var-dumper: 5.*
README
Utilities to easily test event sourced systems based on Orkestra and Symfony using a fluent API.
Installation
composer require morebec/orkestra-orkestra-exceptions
Usage:
class RegisterCustomerCommandHandlerTest extends EventSourcedTestCase { /** * @return void * @throws Throwable */ public function test(): void { $customerId = uniqid('cus_', true); $this ->defineScenario() ->givenCurrentDateIs(new DateTime("2020-01-01")) ->whenCommand(from(static function() use ($customerId) { $command = new RegistercustomerCommand(); $command->customerId = $customerId; return $command; })) ->messageBusShouldRespondWithPayload(null) ->messageBusShouldRespondWithStatusCodeSucceeded() ->expectSingleEventSameAs(from(static function() use ($customerId) { $event = new CustomerRegisteredEvent(); $event->customerId = $customerId; return $event; })) ->runScenario() ; } }