https://github.com/morebec/orkestra-event-sourcing-testing
Utilities to easily test event sourced systems based on Orkestra and Symfony
https://github.com/morebec/orkestra-event-sourcing-testing
Last synced: about 1 year ago
JSON representation
Utilities to easily test event sourced systems based on Orkestra and Symfony
- Host: GitHub
- URL: https://github.com/morebec/orkestra-event-sourcing-testing
- Owner: Morebec
- License: apache-2.0
- Created: 2021-10-21T07:54:22.000Z (over 4 years ago)
- Default Branch: 2.x
- Last Pushed: 2023-03-31T18:46:38.000Z (about 3 years ago)
- Last Synced: 2025-02-01T23:45:07.920Z (over 1 year ago)
- Language: PHP
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Event Sourcing Testing
Utilities to easily test event sourced systems based on Orkestra and Symfony using
a fluent API.
## Installation
```shell
composer require morebec/orkestra-orkestra-exceptions
```
## Usage:
```php
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()
;
}
}
```