예제 #1
0
 /**
  * Creates an answer binder proxy associated with the matchers from the constructor and the object passed here
  *
  * @param Phake_IMock $obj
  *
  * @return Phake_Proxies_AnswerBinderProxy
  */
 public function isCalledOn(Phake_IMock $obj)
 {
     $context = $this->static ? get_class($obj) : $obj;
     $call = $this->static ? '__callStatic' : '__call';
     $matcher = new Phake_Matchers_MethodMatcher($call, $this->argumentMatcher);
     $binder = new Phake_Stubber_AnswerBinder($matcher, Phake::getInfo($context)->getStubMapper());
     return new Phake_Proxies_AnswerBinderProxy($binder);
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
 /**
  * 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);
 }
예제 #4
0
 /**
  * Test retrieving mock name
  */
 public function testMockName()
 {
     $newClassName = __CLASS__ . '_TestClass18';
     $mockedClass = 'PhakeTest_MockedClass';
     $this->classGen->generate($newClassName, $mockedClass, $this->infoRegistry);
     $callRecorder = $this->getMock('Phake_CallRecorder_Recorder');
     $stubMapper = $this->getMock('Phake_Stubber_StubMapper');
     $answer = $this->getMock('Phake_Stubber_IAnswer');
     $mock = $this->classGen->instantiate($newClassName, $callRecorder, $stubMapper, $answer);
     $this->assertEquals('PhakeTest_MockedClass', $mock::__PHAKE_name);
     $this->assertEquals('PhakeTest_MockedClass', Phake::getInfo($mock)->getName());
 }
예제 #5
0
파일: Phake.php 프로젝트: kore/Phake
 /**
  * Allows for verifying that no other interaction occurred with a mock object outside of what has already been
  * verified
  *
  * @param Phake_IMock $mock
  */
 public static function verifyNoOtherInteractions(Phake_IMock $mock)
 {
     $callRecorder = Phake::getInfo($mock)->getCallRecorder();
     $verifier = new Phake_CallRecorder_Verifier($callRecorder, $mock);
     self::getClient()->processVerifierResult($verifier->verifyNoOtherCalls());
     $sCallRecorder = Phake::getInfo(get_class($mock))->getCallRecorder();
     $sVerifier = new Phake_CallRecorder_Verifier($sCallRecorder, get_class($mock));
     self::getClient()->processVerifierResult($sVerifier->verifyNoOtherCalls());
 }