/** * Tests the factorying of multiple matchers */ public function testCreatingMultipleMatchers() { $arguments = array('foo', $argMatcher = $this->getMock('Phake_Matchers_IArgumentMatcher'), $this->getMock('PHPUnit_Framework_Constraint')); $matchers = $this->factory->createMatcherArray($arguments); $this->assertInstanceOf('Phake_Matchers_EqualsMatcher', $matchers[0]); $this->assertSame($argMatcher, $matchers[1]); $this->assertInstanceOf('Phake_Matchers_PHPUnitConstraintAdapter', $matchers[2]); }
/** * Assigns a matcher to the captor. * * This allows an argument to only be captured if the argument meets a specific criteria. This * is useful if one method is called multiple times. * * The same matcher factory used by the verifier and stubber is used here. * * @param mixed $matcher * * @return Phake_Matchers_ArgumentCaptor the current instance */ public function when($matcher) { $factory = new Phake_Matchers_Factory(); $this->matcher = $factory->createMatcher($matcher); return $this; }
/** * A magic call to instantiate an Answer Binder Proxy. * * @param string $method * @param array $arguments * * @return Phake_Proxies_AnswerBinderProxy */ public function __call($method, array $arguments) { $matcher = new Phake_Matchers_MethodMatcher($method, $this->matcherFactory->createMatcherChain($arguments)); $binder = new Phake_Stubber_AnswerBinder($matcher, Phake::getInfo($this->obj)->getStubMapper()); return new Phake_Proxies_AnswerBinderProxy($binder); }
/** * A magic call to instantiate an Answer Binder Proxy. * * @param string $method * @param array $arguments * * @return Phake_Proxies_AnswerBinderProxy */ public function __call($method, array $arguments) { $matcher = new Phake_Matchers_MethodMatcher($method, $this->matcherFactory->createMatcherArray($arguments)); $binder = new Phake_Stubber_AnswerBinder($this->obj, $matcher, $this->mockReader); return new Phake_Proxies_AnswerBinderProxy($binder); }
public function testMatcherChainReturnsNullOnNoArguments() { $this->assertNull($this->factory->createMatcherChain(array())); }
/** * A call magic method to provide a more fluent interface to the verifier. * * @param string $method * @param array $arguments * * @return Phake_CallRecorder_VerifierResult */ public function __call($method, array $arguments) { $expectation = new Phake_CallRecorder_CallExpectation($this->verifier->getObject(), $method, $this->matcherFactory->createMatcherChain($arguments), $this->mode); $result = $this->verifier->verifyCall($expectation); return $this->client->processVerifierResult($result); }
/** * Returns a new stubber specifically for the __call() method * * @param mixed ... A vararg containing the expected arguments for this call * * @return \Phake_Proxies_CallStubberProxy */ public static function whenStaticCallMethodWith() { $arguments = func_get_args(); $factory = new Phake_Matchers_Factory(); return new Phake_Proxies_CallStubberProxy($factory->createMatcherChain($arguments), true); }
/** * Returns a new stubber specifically for the __call() method * * @param mixed ... A vararg containing the expected arguments for this call * * @return \Phake_Proxies_CallStubberProxy */ public static function whenCallMethodWith() { $arguments = func_get_args(); $factory = new Phake_Matchers_Factory(); return new Phake_Proxies_CallStubberProxy($factory->createMatcherArray($arguments), new Phake_MockReader()); }