Example #1
0
 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')]);
 }
Example #2
0
 function storeEvents($assert)
 {
     $store = new MemoryEventStore();
     $application = new CommandQueryApplication($store);
     $application->handle(new Foo2('that'));
     $assert($store->allEvents(), [new Fooed('that happened')]);
 }
Example #3
0
 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']);
 }
Example #4
0
 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');
 }
Example #5
0
 function handleCommands($assert)
 {
     $application = new CommandQueryApplication(new MemoryEventStore());
     $application->handle(new Foo('that'));
     $assert(FooAggregate::$handled, [new Foo('that')]);
 }