Example #1
0
 /**
  * Searches for calls by method name & arguments wildcard.
  *
  * @param string            $methodName
  * @param ArgumentsWildcard $wildcard
  *
  * @return Call[]
  */
 public function findCalls($methodName, ArgumentsWildcard $wildcard)
 {
     return array_values(array_filter($this->recordedCalls, function ($call) use($methodName, $wildcard) {
         return $methodName === $call->getMethodName() && 0 < $wildcard->scoreArguments($call->getArguments());
     }));
 }
Example #2
0
 /**
  * @param \Prophecy\Argument\ArgumentsWildcard $wildcard
  */
 function it_finds_recorded_calls_by_a_method_name_and_arguments_wildcard($objectProphecy, $wildcard)
 {
     $objectProphecy->getMethodProphecies()->willReturn(array());
     $this->makeCall($objectProphecy, 'getName', array('world'));
     $this->makeCall($objectProphecy, 'getName', array('everything'));
     $this->makeCall($objectProphecy, 'setName', array(42));
     $wildcard->scoreArguments(array('world'))->willReturn(false);
     $wildcard->scoreArguments(array('everything'))->willReturn(10);
     $calls = $this->findCalls('getName', $wildcard);
     $calls->shouldHaveCount(1);
     $calls[0]->getMethodName()->shouldReturn('getName');
     $calls[0]->getArguments()->shouldReturn(array('everything'));
 }