Ejemplo n.º 1
0
 /**
  * Tests setting a stub on a method in the stubbable object
  */
 public function testIsCalledOn()
 {
     $mock = $this->getMock('Phake_IMock');
     $this->obj->recordCall(new Phake_CallRecorder_Call($mock, '__call', array('foo', array()), new Phake_MockReader()));
     $verifier = $this->proxy->isCalledOn($mock);
     $this->assertEquals(1, count($verifier));
 }
Ejemplo n.º 2
0
 public function verifyNoCalls()
 {
     $result = true;
     $reportedCalls = array();
     foreach ($this->recorder->getAllCalls() as $call) {
         $result = false;
         $reportedCalls[] = $call->__toString();
     }
     if ($result) {
         return new Phake_CallRecorder_VerifierResult(true, array());
     } else {
         $desc = 'Expected no interaction with mock' . "\n" . 'Invocations:' . "\n  ";
         return new Phake_CallRecorder_VerifierResult(false, array(), $desc . implode("\n  ", $reportedCalls));
     }
 }
Ejemplo n.º 3
0
 public function invoke($mock, $method, array $arguments, array &$argumentReference)
 {
     if ($method == '__call' || $method == '__callStatic') {
         $this->callRecorder->recordCall(new Phake_CallRecorder_Call($mock, $arguments[0], $arguments[1]));
     }
 }
Ejemplo n.º 4
0
 /**
  * Tests that the verifier will only return calls made on the same object
  */
 public function testVerifierBeingCalledWithMixedCallRecorder()
 {
     $recorder = new Phake_CallRecorder_Recorder();
     $obj1 = $this->getMock('Phake_IMock');
     $obj2 = $this->getMock('Phake_IMock');
     $expectation = new Phake_CallRecorder_CallExpectation($obj1, 'foo', array(), $this->verifierMode, $this->mockReader);
     $recorder->recordCall(new Phake_CallRecorder_Call($obj1, 'foo', array(), new Phake_MockReader()));
     $recorder->recordCall(new Phake_CallRecorder_Call($obj2, 'foo', array(), new Phake_MockReader()));
     $verifier = new Phake_CallRecorder_Verifier($recorder, $obj1);
     Phake::when($this->verifierMode)->verify(Phake::anyParameters())->thenReturn(new Phake_CallRecorder_VerifierMode_Result(true, ''));
     $this->assertEquals(1, count($verifier->verifyCall($expectation)->getMatchedCalls()));
 }
Ejemplo n.º 5
0
 /**
  * Tests an internal php nested object issue (#47)
  */
 public function testRetrieveCallInfoUsesStrictChecking()
 {
     $objA = new stdClass();
     $objB = new stdClass();
     $objA->b = $objB;
     $objB->a = $objA;
     $objC = new stdClass();
     $objD = new stdClass();
     $objC->b = $objD;
     $objD->a = $objC;
     $call = new Phake_CallRecorder_Call($this->mock, 'someMethod', array($objA), new Phake_MockReader());
     $callRecorder = new Phake_CallRecorder_Recorder();
     $callRecorder->recordCall($call);
     $checkCall = new Phake_CallRecorder_Call($this->mock, 'someMethod', array($objC), new Phake_MockReader());
     $this->assertNull($callRecorder->getCallInfo($checkCall));
 }
Ejemplo n.º 6
0
 public function invoke($mock, $method, array $arguments, array &$argumentReference)
 {
     $this->callRecorder->recordCall(new Phake_CallRecorder_Call($mock, $method, $arguments));
 }
Ejemplo n.º 7
0
 public function testMarkingCallsVerified()
 {
     $call1 = new Phake_CallRecorder_Call($this->mock, 'someMethod', array());
     $call2 = new Phake_CallRecorder_Call($this->mock, 'someMethod', array());
     $call3 = new Phake_CallRecorder_Call($this->mock, 'someMethod', array());
     $callRecorder = new Phake_CallRecorder_Recorder();
     $callRecorder->recordCall($call1);
     $callRecorder->recordCall($call2);
     $callRecorder->markCallVerified($call2);
     $callRecorder->recordCall($call3);
     $this->assertEquals(array($call1, $call3), $callRecorder->getUnverifiedCalls());
 }