/** * @test */ public function it_publishes_decorated_events() { $projector = new TestMetadataPublishedProjector(); $this->eventBus->subscribe($projector); $repository = new EventSourcingRepository($this->eventStore, $this->eventBus, get_class($this->createAggregate()), new PublicConstructorAggregateFactory(), array(new MetadataEnrichingEventStreamDecorator(array(new TestDecorationMetadataEnricher())))); $aggregate = $this->createAggregate(); $aggregate->apply(new DidNumberEvent(42)); $repository->save($aggregate); $metadata = $projector->getMetadata(); $data = $metadata->serialize(); $this->assertArrayHasKey('decoration_test', $data); $this->assertEquals('I am a decorated test', $data['decoration_test']); }
/** * @param object[] $expectedEvents */ protected function assertTracedEvents($expectedEvents) { $events = $this->eventBus->getEvents(); $this->assertEquals($expectedEvents, $events); }