public function testStoreEvent() { $es1 = new MemoryEventStore(); $es2 = new MemoryEventStore(); $chainingEventStore = new ChainingEventStore([$es1, $es2]); $event = new GenericEventMessage(new SomeEvent()); $chainingEventStore->store($event); $events1 = $es1->read(); $this->assertEquals([$event], $events1); $events2 = $es2->read(); $this->assertEquals([$event], $events2); }
public function testFiltering() { $eventStore = new MemoryEventStore(); $filteringEventStore = new FilteringEventStore($eventStore, new SomeEventFilter()); $validEvent = new GenericEventMessage(new SomeEvent(), Metadata::from(['valid' => true])); $invalidEvent = new GenericEventMessage(new SomeEvent(), Metadata::from(['valid' => false])); $filteringEventStore->store($validEvent); $filteringEventStore->store($invalidEvent); $events = $eventStore->read(); $this->assertContains($validEvent, $events); $this->assertNotContains($invalidEvent, $events); }