function protectInvariants() { $application = new CommandQueryApplication(new MemoryEventStore()); $application->handle(new Foo4()); try { $application->handle(new Foo4()); } catch (\Exception $e) { return; } throw new Failure('Should have thrown an exception'); }
function reactToEvents($assert) { $application = new CommandQueryApplication(new MemoryEventStore()); $application->addListener(new StaticListener(new FooListener())); $application->handle(new Foo3('this')); $assert(FooListener::$heard, [new Fooed3('this happened')]); }
function storeEvents($assert) { $store = new MemoryEventStore(); $application = new CommandQueryApplication($store); $application->handle(new Foo2('that')); $assert($store->allEvents(), [new Fooed('that happened')]); }
function projectEvents($assert) { $store = new MemoryEventStore(); $application = new CommandQueryApplication($store); $store->append(new Fooed5('that happened'), 'foo'); $bar = $application->handle(new Bar()); $assert($bar->fooed, ['So that happened']); }
function handleCommands($assert) { $application = new CommandQueryApplication(new MemoryEventStore()); $application->handle(new Foo('that')); $assert(FooAggregate::$handled, [new Foo('that')]); }