/**
  * @param \PHPUnit_Framework_MockObject_MockObject $mockObject
  * @param $methodName
  * @param ReturnValue|null $returnValue
  */
 public function setMockObjectExpectation(&$mockObject, $methodName, ReturnValue $returnValue = null)
 {
     if ($returnValue->isCallable()) {
         // callback
         $mockObject->expects($this->invokedRecorder)->method($methodName)->willReturnCallback($returnValue->getValue());
     } else {
         if ($returnValue->isSelf()) {
             // ->
             $mockObject->expects($this->invokedRecorder)->method($methodName)->willReturn($mockObject);
         } else {
             // value
             $mockObject->expects($this->invokedRecorder)->method($methodName)->willReturn($returnValue->getValue());
         }
     }
 }
Example #2
0
 /**
  * @param $mockObject
  */
 protected function setMockObjectExpectation(&$mockObject)
 {
     foreach ($this->methods as $method => $returnValue) {
         $this->instanceForger->setMockObjectExpectation($mockObject, $method, ReturnValue::from($returnValue));
     }
 }
 public function __willReturnCallable()
 {
     return $this->__returnValue->isCallable();
 }
 /**
  * @param $functionName
  * @param $returnValue
  *
  * @return mixed|null|Call\Verifier\InstanceMethodCallVerifier|static
  * @throws \Exception
  */
 private static function _replace($functionName, $returnValue)
 {
     $request = ReplacementRequest::on($functionName);
     $returnValue = ReturnValue::from($returnValue);
     $methodName = $request->getMethodName();
     if ($request->isClass()) {
         return self::get_instance_replacement_chain_head($functionName);
     }
     if ($request->isInstanceMethod()) {
         return self::get_instance_replacement($request, $returnValue);
     }
     return self::get_function_or_static_method_replacement($functionName, $returnValue, $request, $methodName);
 }