예제 #1
0
 public function matches($item)
 {
     if (!is_array($item)) {
         return false;
     }
     $payloads = array();
     foreach ($item as $listItem) {
         if ($listItem instanceof MessageInterface) {
             $payloads[] = $listItem->getPayload();
         } else {
             $payloads[] = $item;
         }
     }
     return $this->matcher->matches($payloads);
 }
예제 #2
0
 public function assertMismatchDescription($expected, \Hamcrest\Matcher $matcher, $arg)
 {
     $description = new \Hamcrest\StringDescription();
     $this->assertFalse($matcher->matches($arg), 'Precondtion: Matcher should not match item');
     $matcher->describeMismatch($arg, $description);
     $this->assertEquals($expected, (string) $description, 'Expected mismatch description');
 }
예제 #3
0
 /**
  * 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));
     }
 }
예제 #4
0
 /**
  * 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));
     }
 }
예제 #5
0
 /**
  * Matches if the result of the XPath expression matches the configured
  * matcher or evaluates to <code>true</code> if there is none.
  *
  * @param mixed $result result of the XPath expression
  * @param Description $mismatchDescription
  * @return bool
  */
 protected function matchesExpression($result, Description $mismatchDescription)
 {
     if ($this->_matcher === null) {
         if ($result) {
             return true;
         }
         $mismatchDescription->appendText('XPath expression result was ')->appendValue($result);
     } else {
         if ($this->_matcher->matches($result)) {
             return true;
         }
         $mismatchDescription->appendText('XPath expression result ');
         $this->_matcher->describeMismatch($result, $mismatchDescription);
     }
     return false;
 }
예제 #6
0
 public function expectStoredEventsMatching(Matcher $matcher)
 {
     if (!$matcher->matches($this->storedEvents)) {
         $this->reporter->reportWrongEventDescription($this->storedEvents, $this->descriptionOf($matcher), $this->actualException);
     }
     return $this;
 }
예제 #7
0
 public function matches($item)
 {
     return $item instanceof MessageInterface && $this->payloadMatcher->matches($item->getPayload());
 }