public function testFixtureApi_WhenEventOccurs() { $aggregate1 = Uuid::uuid1()->toString(); $aggregate2 = Uuid::uuid1()->toString(); $fixture = new AnnotatedSagaTestFixture(StubSaga::class); $validator = $fixture->givenAggregate($aggregate1)->published([new GenericEventMessage(new TriggerSagaStartEvent($aggregate1)), new GenericEventMessage(new TriggerExistingSagaEvent($aggregate1))])->andThenAggregate($aggregate2)->published([new GenericEventMessage(new TriggerSagaStartEvent($aggregate2))])->whenAggregate($aggregate1)->publishes(new GenericEventMessage(new TriggerSagaEndEvent($aggregate1))); $validator->expectActiveSagas(1); $validator->expectAssociationWith("identifier", $aggregate2); $validator->expectNoAssociationWith("identifier", $aggregate1); $validator->expectDispatchedCommandsEqualTo(array()); $validator->expectNoDispatchedCommands(); $validator->expectPublishedEventsMatching(Matchers::noEvents()); /* TODO timers validator.expectScheduledEventOfType(Duration.standardMinutes(10), TimerTriggeredEvent.class); validator.expectScheduledEventMatching(Duration.standardMinutes(10), messageWithPayload(CoreMatchers.any( TimerTriggeredEvent.class))); validator.expectScheduledEvent(Duration.standardMinutes(10), new TimerTriggeredEvent(aggregate1.toString())); validator.expectScheduledEventOfType(fixture.currentTime().plusMinutes(10), TimerTriggeredEvent.class); validator.expectScheduledEventMatching(fixture.currentTime().plusMinutes(10), messageWithPayload(CoreMatchers.any(TimerTriggeredEvent.class))); validator.expectScheduledEvent(fixture.currentTime().plusMinutes(10), new TimerTriggeredEvent(aggregate1.toString())); */ }
/** * @expectedException \Governor\Framework\Test\GovernorAssertionError */ public function testAssertPublishedEventsWithNoEventsMatcherThrowsAssertionErrorIfEventWasPublished() { $this->testSubject->handle(new GenericEventMessage(new MyOtherEvent())); $this->testSubject->assertPublishedEventsMatching(Matchers::noEvents()); }