function it_records_calls_made_through_makeCall_method(ObjectProphecy $objectProphecy, ArgumentsWildcard $wildcard) { $wildcard->scoreArguments(array(5, 2, 3))->willReturn(10); $objectProphecy->getMethodProphecies()->willReturn(array()); $this->makeCall($objectProphecy, 'setValues', array(5, 2, 3)); $calls = $this->findCalls('setValues', $wildcard); $calls->shouldHaveCount(1); $calls[0]->shouldBeAnInstanceOf('Prophecy\\Call\\Call'); $calls[0]->getMethodName()->shouldReturn('setValues'); $calls[0]->getArguments()->shouldReturn(array(5, 2, 3)); $calls[0]->getReturnValue()->shouldReturn(null); }
private function createUnexpectedCallException(ObjectProphecy $prophecy, $methodName, array $arguments) { $classname = get_class($prophecy->reveal()); $argstring = implode(', ', array_map(array($this->util, 'stringify'), $arguments)); $expected = implode("\n", array_map(function ($methodProphecy) { return sprintf(' - %s(%s)', $methodProphecy->getMethodName(), $methodProphecy->getArgumentsWildcard()); }, call_user_func_array('array_merge', $prophecy->getMethodProphecies()))); return new UnexpectedCallException(sprintf("Method call:\n" . " %s->%s(%s)\n" . "was not expected.\n" . "Expected calls are:\n%s", $classname, $methodName, $argstring, $expected), $prophecy, $methodName, $arguments); }
/** * @param \Prophecy\Prophecy\ObjectProphecy $base_entity_type * @return \Prophecy\Prophecy\ObjectProphecy */ protected function getEntityType(ObjectProphecy $base_entity_type = NULL) { $entity_type = $this->prophesize(EntityTypeInterface::class); if ($base_entity_type) { foreach ($base_entity_type->getMethodProphecies() as $method => $prophecies) { foreach ($prophecies as $prophecy) { $entity_type->addMethodProphecy(clone $prophecy); } } } return $entity_type; }