public function testVerifierModifiesFailureDescriptionWithOtherCalls() { $expectation = new Phake_CallRecorder_CallExpectation($this->obj, 'foo', array(new Phake_Matchers_EqualsMatcher('test')), $this->verifierMode, $this->mockReader); Phake::when($this->verifierMode)->__toString()->thenReturn('exactly 1 times'); $return = new Phake_CallRecorder_CallInfo($this->callArray[1], new Phake_CallRecorder_Position(0)); Phake::when($this->recorder)->getCallInfo(Phake::anyParameters())->thenReturn($return); Phake::when($this->verifierMode)->verify(Phake::anyParameters())->thenReturn(new Phake_CallRecorder_VerifierMode_Result(false, 'actually called 0 times')); $expected_msg = "Expected mock->foo(equal to <string:test>) to be called exactly 1 times, actually called 0 times.\n" . "Other Invocations:\n" . " mock->foo()\n" . " mock->foo(<string:bar>, <string:foo>)\n" . " mock->foo()"; $this->assertEquals(new Phake_CallRecorder_VerifierResult(false, array(), $expected_msg), $this->verifier->verifyCall($expectation)); }
public function testVerifyMarksMatchedCallsAsVerified() { $expectation = new Phake_CallRecorder_CallExpectation($this->obj, 'bar', null, $this->verifierMode); $return = new Phake_CallRecorder_CallInfo($this->callArray[1], new Phake_CallRecorder_Position(0)); Phake::when($this->recorder)->getCallInfo($this->callArray[1])->thenReturn($return); Phake::when($this->verifierMode)->verify(Phake::anyParameters())->thenReturn(new Phake_CallRecorder_VerifierMode_Result(true, '')); $this->verifier->verifyCall($expectation); Phake::verify($this->recorder)->markCallVerified($this->callArray[1]); Phake::verify($this->recorder)->markCallVerified(Phake::anyParameters()); }
/** * Verifies that the call to __call was made on the given object with the parameters passed into the constructor * * @param Phake_IMock $obj * @param Phake_CallRecorder_IVerifierMode $verifierMode * * @return array */ public function isCalledOn(Phake_IMock $obj, Phake_CallRecorder_IVerifierMode $verifierMode = null) { if ($verifierMode === null) { $verifierMode = new Phake_CallRecorder_VerifierMode_Times(1); } $verifier = new Phake_CallRecorder_Verifier($this->mockReader->getCallRecorder($obj), $obj); $expectation = new Phake_CallRecorder_CallExpectation($obj, '__call', $this->arguments, $verifierMode, $this->mockReader); $result = $verifier->verifyCall($expectation); return $this->client->processVerifierResult($result); }
/** * Verifies that the call to __call was made on the given object with the parameters passed into the constructor * * @param Phake_IMock $obj * @param Phake_CallRecorder_IVerifierMode $verifierMode * * @return array */ public function isCalledOn(Phake_IMock $obj, Phake_CallRecorder_IVerifierMode $verifierMode = null) { if ($verifierMode === null) { $verifierMode = new Phake_CallRecorder_VerifierMode_Times(1); } $context = $this->static ? get_class($obj) : $obj; $call = $this->static ? '__callStatic' : '__call'; $verifier = new Phake_CallRecorder_Verifier(Phake::getInfo($context)->getCallRecorder(), $obj); $expectation = new Phake_CallRecorder_CallExpectation($context, $call, $this->argumentMatcher, $verifierMode); $result = $verifier->verifyCall($expectation); return $this->client->processVerifierResult($result); }
/** * 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); }