/** * Asserts that events have been published matching the given <code>matcher</code>. * * @param Matcher $matcher The matcher that will validate the actual events * @throws GovernorAssertionError */ public function assertPublishedEventsMatching(Matcher $matcher) { if (!$matcher->matches($this->publishedEvents)) { $expectedDescription = new StringDescription(); $actualDescription = new StringDescription(); $matcher->describeTo($expectedDescription); DescriptionUtils::describe($this->publishedEvents, $actualDescription); throw new GovernorAssertionError(sprintf("Published events did not match.\nExpected:\n<%s>\n\nGot:\n<%s>\n", $expectedDescription, $actualDescription)); } }
/** * Assert that commands matching the given <code>matcher</code> has been dispatched on the command bus. * * @param Matcher $matcher The matcher validating the actual commands * @throws GovernorAssertionError */ public function assertDispatchedMatching(Matcher $matcher) { if (!$matcher->matches($this->commandBus->getDispatchedCommands())) { $expectedDescription = new StringDescription(); $actualDescription = new StringDescription(); $matcher->describeTo($expectedDescription); DescriptionUtils::describe($this->commandBus->getDispatchedCommands(), $actualDescription); throw new GovernorAssertionError(sprintf("Incorrect dispatched command. Expected <%s>, but got <%s>", $expectedDescription, $actualDescription)); } }