function it_should_return_empty_string_if_argument_counts_do_not_match(UnexpectedCallException $exception, ObjectProphecy $objectProphecy, MethodProphecy $prophecy, ArgumentsWildcard $wildcard) { $exception->getObjectProphecy()->willReturn($objectProphecy); $exception->getArguments()->willReturn(array('a', 'b')); $exception->getMethodName()->shouldBeCalled(); $objectProphecy->getMethodProphecies(Argument::any())->willReturn(array($prophecy)); $objectProphecy->findProphecyMethodCalls(Argument::any(), Argument::any())->willReturn(array()); $prophecy->getArgumentsWildcard()->willReturn($wildcard); $wildcard->getTokens()->willReturn(array('a')); $this->presentDifference($exception)->shouldReturn(''); }
/** * @param UnexpectedCallException $exception * @return string */ public function presentDifference(UnexpectedCallException $exception) { $actualArguments = $exception->getArguments(); $methodProphecies = $exception->getObjectProphecy()->getMethodProphecies($exception->getMethodName()); if ($this->noMethodPropheciesForUnexpectedCall($methodProphecies)) { return ''; } $presentedMethodProphecy = $this->findFirstUnexpectedArgumentsCallProphecy($methodProphecies, $exception); if (is_null($presentedMethodProphecy)) { return ''; } $expectedTokens = $presentedMethodProphecy->getArgumentsWildcard()->getTokens(); if ($this->parametersCountMismatch($expectedTokens, $actualArguments)) { return ''; } $expectedArguments = $this->convertArgumentTokensToDiffableValues($expectedTokens); $text = $this->generateArgumentsDifferenceText($actualArguments, $expectedArguments); return $text; }