private function createEqualToMatchers(array $expected) { $matchers = array(); foreach ($expected as $event) { $matchers[] = Matchers::equalTo($event); } return $matchers; }
public function setUp() { $this->mockMatcher1 = \Phake::mock(Matcher::class); $this->mockMatcher2 = \Phake::mock(Matcher::class); $this->mockMatcher3 = \Phake::mock(Matcher::class); $this->testSubject = Matchers::listWithAllOf(array($this->mockMatcher1, $this->mockMatcher2, $this->mockMatcher3)); $this->stubEvent1 = new StubEvent1(); $this->stubEvent2 = new StubEvent2(); \Phake::when($this->mockMatcher1)->matches(\Phake::anyParameters())->thenReturn(true); \Phake::when($this->mockMatcher2)->matches(\Phake::anyParameters())->thenReturn(true); \Phake::when($this->mockMatcher3)->matches(\Phake::anyParameters())->thenReturn(true); }
public function testFixtureApi_WhenEventIsPublishedToEventBus() { $aggregate1 = Uuid::uuid1()->toString(); $aggregate2 = Uuid::uuid1()->toString(); $fixture = new AnnotatedSagaTestFixture(StubSaga::class); $validator = $fixture->givenAggregate($aggregate1)->published(array(new TriggerSagaStartEvent($aggregate1), new TriggerExistingSagaEvent($aggregate1)))->whenAggregate($aggregate1)->publishes(new TriggerExistingSagaEvent($aggregate1)); $validator->expectActiveSagas(1); $validator->expectAssociationWith("identifier", $aggregate1); $validator->expectNoAssociationWith("identifier", $aggregate2); //validator.expectScheduledEventMatching(Duration.standardMinutes(10), // Matchers.messageWithPayload(CoreMatchers.any(Object.class))); $validator->expectDispatchedCommandsEqualTo(array()); $validator->expectPublishedEventsMatching(Matchers::listWithAnyOf(array(Matchers::messageWithPayload(CoreMatchers::any(SagaWasTriggeredEvent::class))))); }
public function setUp() { $this->expectedEvent = new MyEvent($this->aggregateId, array("a" => "b")); $this->testSubject = Matchers::equalTo($this->expectedEvent); }
public function testMatch_ExcessIsRefused() { $this->testSubject = Matchers::exactSequenceOf(array($this->mockMatcher1, $this->mockMatcher2, $this->mockMatcher3, Matchers::andNoMore())); $this->assertFalse($this->testSubject->matches(array($this->stubEvent1, $this->stubEvent2, $this->stubEvent3, new StubEvent()))); \Phake::verify($this->mockMatcher1, \Phake::times(1))->matches($this->stubEvent1); \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent2); \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent3); \Phake::verify($this->mockMatcher2, \Phake::never())->matches($this->stubEvent1); \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent2); \Phake::verify($this->mockMatcher2, \Phake::never())->matches($this->stubEvent3); \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent1); \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent2); \Phake::verify($this->mockMatcher3, \Phake::times(1))->matches($this->stubEvent3); }
/** * Asserts that the sagas did not dispatch any commands. Only commands as a result of the event in the "when" stage * of ths fixture are recorded. * * @return FixtureExecutionResultInterface the FixtureExecutionResult for method chaining */ public function expectNoDispatchedCommands() { $this->commandValidator->assertDispatchedMatching(Matchers::noCommands()); return $this; }
public function testMatcherMatchesVoidAndNull() { $this->assertTrue(Matchers::nothing()->matches(null)); $this->assertFalse(Matchers::nothing()->matches(new \stdClass())); }
/** * @expectedException \Governor\Framework\Test\GovernorAssertionError */ public function testAssertPublishedEventsWithNoEventsMatcherThrowsAssertionErrorIfEventWasPublished() { $this->testSubject->handle(new GenericEventMessage(new MyOtherEvent())); $this->testSubject->assertPublishedEventsMatching(Matchers::noEvents()); }