Exemple #1
0
 public function testVerifyNoOtherCallsFails()
 {
     Phake::when($this->recorder)->getUnverifiedCalls()->thenReturn($this->callArray);
     $verifierResult = $this->verifier->verifyNoOtherCalls();
     $this->assertFalse($verifierResult->getVerified());
     $expected_msg = "Expected no interaction with mock\n" . "Invocations:\n" . "  Phake_IMock->foo()\n" . "  Phake_IMock->bar()\n" . "  Phake_IMock->foo(<string:bar>, <string:foo>)\n" . "  Phake_IMock->foo()";
     $this->assertEquals($expected_msg, $verifierResult->getFailureDescription());
     $this->assertEmpty($verifierResult->getMatchedCalls());
 }
Exemple #2
0
 /**
  * A magic call to verify a call with any parameters.
  *
  * @param string $method
  *
  * @throws InvalidArgumentException if $method is not a valid parameter/method name
  *
  * @return Phake_CallRecorder_VerifierResult
  */
 public function __get($method)
 {
     $obj = $this->verifier->getObject();
     if (is_string($method) && ctype_digit($method[0])) {
         throw new InvalidArgumentException('String parameter to __get() cannot start with an integer');
     }
     if (!is_string($method) && !is_object($method)) {
         $message = sprintf('Parameter to __get() must be a string, %s given', gettype($method));
         throw new InvalidArgumentException($message);
     }
     if (method_exists($obj, '__get') && !(is_string($method) && method_exists($obj, $method))) {
         return $this->__call('__get', array($method));
     }
     return $this->__call($method, array(new Phake_Matchers_AnyParameters()));
 }
Exemple #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);
     }
     $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);
 }
Exemple #5
0
 /**
  * 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());
 }
Exemple #6
0
 public function testVerifyNoCallsFailsWithOtherCallsListed()
 {
     $expected_msg = "Expected no interaction with mock\n" . "Invocations:\n" . "  mock->foo()\n" . "  mock->bar()\n" . "  mock->foo(<string:bar>, <string:foo>)\n" . "  mock->foo()";
     $this->assertEquals(new Phake_CallRecorder_VerifierResult(false, array(), $expected_msg), $this->verifier->verifyNoCalls());
 }
Exemple #7
0
 /**
  * Allows for verifying that no interaction occurred with a mock object
  *
  * @param Phake_IMock $mock
  */
 public static function verifyNoInteraction(Phake_IMock $mock)
 {
     foreach (func_get_args() as $mock) {
         $reader = new Phake_MockReader();
         $verifier = new Phake_CallRecorder_Verifier($reader->getCallRecorder($mock), $mock);
         self::getClient()->processVerifierResult($verifier->verifyNoCalls());
     }
 }