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