getReturnValues() public static method

public static getReturnValues ( ) : array
return array
 /**
  * @expectedException PHPUnit_Framework_AssertionFailedError
  */
 public function testChainStubbingCorruptDataReturnValue()
 {
     $mock = ShortifyPunit::mock('SimpleClassForMocking');
     ShortifyPunit::when($mock)->first_method()->second_method(2, 3)->returns(1);
     $response = ShortifyPunit::getReturnValues();
     $response[get_class($mock)][$mock->getShortifyPunitInstanceId()]['first_method']['a:0:{}']['second_method']['a:2:{i:0;i:2;i:1;i:3;}'] = ['response' => []];
     ShortifyPunit::setReturnValues($response);
     $mock->first_method()->second_method(2, 3);
 }
Example #2
0
 /**
  * Getting the call counter for the specific chained
  * stubbing methods
  *
  * @param $methods
  * @return int
  */
 private function getChainedMockCounter($methods)
 {
     $mockReturnValues = ShortifyPunit::getReturnValues();
     $mockResponse = $mockReturnValues[$this->mockedClass][$this->instanceId];
     foreach ($methods as $method) {
         $methodName = key($method);
         $args = $method[$methodName];
         $serializedArgs = serialize($args);
         if (!isset($mockResponse[$methodName][$serializedArgs])) {
             if (!isset($mockResponse[$methodName])) {
                 break;
             }
             // try to finding matching Hamcrest-API Function (anything(), equalTo())
             $serializedArgs = static::checkMatchingArguments($mockResponse[$methodName], $args);
             if (is_null($serializedArgs)) {
                 break;
             }
         }
         $mockResponse = $mockResponse[$methodName][$serializedArgs];
     }
     return isset($mockResponse['response']['counter']) ? $mockResponse['response']['counter'] : 0;
 }