/** * {@inheritdoc} */ protected function createDoubleClass(ReflectionClass $class = null, array $interfaces) { $classId = $this->generateClassId($class, $interfaces); if (isset($this->classes[$classId])) { return $this->classes[$classId]; } return $this->classes[$classId] = parent::createDoubleClass($class, $interfaces); }
/** * Initializes Prophet. * * @param null|Doubler $doubler * @param null|RevealerInterface $revealer * @param null|StringUtil $util */ public function __construct(Doubler $doubler = null, RevealerInterface $revealer = null, StringUtil $util = null) { if (null === $doubler) { $doubler = new Doubler(); $doubler->registerClassPatch(new ClassPatch\SplFileInfoPatch()); $doubler->registerClassPatch(new ClassPatch\TraversablePatch()); $doubler->registerClassPatch(new ClassPatch\DisableConstructorPatch()); $doubler->registerClassPatch(new ClassPatch\ProphecySubjectPatch()); $doubler->registerClassPatch(new ClassPatch\ReflectionClassNewInstancePatch()); $doubler->registerClassPatch(new ClassPatch\HhvmExceptionPatch()); $doubler->registerClassPatch(new ClassPatch\MagicCallPatch()); $doubler->registerClassPatch(new ClassPatch\KeywordPatch()); } $this->doubler = $doubler; $this->revealer = $revealer ?: new Revealer(); $this->util = $util ?: new StringUtil(); }
/** * @param \Prophecy\Doubler\Doubler $doubler * @param \Prophecy\Prophecy\ProphecySubjectInterface $double */ function let($doubler, $double) { $doubler->double(null, array())->willReturn($double); $this->beConstructedWith($doubler); }
/** * @param \Prophecy\Doubler\Doubler $doubler * @param \Prophecy\Prophecy\ProphecySubjectInterface $reflection */ function it_returns_new_MethodProphecy_for_different_signatures($doubler, $reflection) { $doubler->double(Argument::any())->willReturn($reflection); $this->addMethodProphecy($methodProphecy1 = $this->getProphecy(3, 2, 1)); $methodProphecy2 = $this->getProphecy(1, 2, 3); $methodProphecy2->shouldNotBe($methodProphecy1); }
/** * @param \Prophecy\Doubler\Doubler $doubler * @param \Prophecy\Prophecy\ProphecySubjectInterface $reflection */ function it_returns_new_MethodProphecy_for_different_signatures($doubler, $reflection) { $doubler->double(Argument::any())->willReturn($reflection); $value = new ObjectProphecySpecFixtureB('ABC'); $value2 = new ObjectProphecySpecFixtureB('CBA'); $this->addMethodProphecy($methodProphecy1 = $this->getProphecy(1, 2, 3, $value)); $methodProphecy2 = $this->getProphecy(1, 2, 3, $value2); $methodProphecy2->shouldNotBe($methodProphecy1); }
function it_returns_new_MethodProphecy_for_all_callback_signatures(Doubler $doubler, ProphecySubjectInterface $reflection) { $doubler->double(Argument::any())->willReturn($reflection); $this->addMethodProphecy($methodProphecy1 = $this->getProphecy(function () { })); $methodProphecy2 = $this->getProphecy(function () { }); $methodProphecy2->shouldNotBe($methodProphecy1); }
function let(Doubler $doubler, ProphecySubjectInterface $double) { $doubler->double(null, array())->willReturn($double); $this->beConstructedWith($doubler); }