Skip to content

Utilities to easily test event sourced systems based on Orkestra and Symfony

License

Notifications You must be signed in to change notification settings

Morebec/orkestra-event-sourcing-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Event Sourcing Testing

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()
        ;
    }
}

About

Utilities to easily test event sourced systems based on Orkestra and Symfony

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages