Пример #1
0
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject $mock
  * @param array $expectedCalls
  * @param object|null $callbacksContext
  */
 public static function addMockExpectedCalls(\PHPUnit_Framework_MockObject_MockObject $mock, array $expectedCalls, $callbacksContext = null)
 {
     $index = 0;
     if ($expectedCalls) {
         foreach ($expectedCalls as $expectedCall) {
             list($method, $arguments, $result) = $expectedCall;
             $methodExpectation = $mock->expects(\PHPUnit_Framework_TestCase::at($index++))->method($method);
             $methodExpectation = call_user_func_array(array($methodExpectation, 'with'), $arguments);
             if (is_string($result) && $callbacksContext && method_exists($callbacksContext, $result)) {
                 $result = $callbacksContext->{$result}();
             }
             $methodExpectation->will(\PHPUnit_Framework_TestCase::returnValue($result));
         }
     } else {
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method(\PHPUnit_Framework_TestCase::anything());
     }
 }
Пример #2
0
/**
 * Returns a matcher that matches when the method it is evaluated for
 * is never executed.
 *
 * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
 * @since  Method available since Release 3.0.0
 */
function never()
{
    return PHPUnit_Framework_TestCase::never();
}
Пример #3
0
 public function invoke(\PHPUnit_Framework_MockObject_Invocation $invocation)
 {
     $returnData = parent::invoke($invocation);
     if (is_string($returnData)) {
         $returnData = array(0, $returnData);
     }
     $mock = clone $this->mock;
     if ($mock instanceof \PHPUnit_Framework_MockObject_MockObject) {
         $mock->expects(\PHPUnit_Framework_TestCase::any())->method('getOutput')->will(\PHPUnit_Framework_TestCase::returnValue($returnData[1]));
         $mock->expects(\PHPUnit_Framework_TestCase::any())->method('getOutputArray')->will(\PHPUnit_Framework_TestCase::returnValue(explode("\n", $returnData[1])));
         $mock->expects(\PHPUnit_Framework_TestCase::any())->method('isExecuted')->will(\PHPUnit_Framework_TestCase::returnValue(TRUE));
         $mock->expects(\PHPUnit_Framework_TestCase::any())->method('getExitStatus')->will(\PHPUnit_Framework_TestCase::returnValue($returnData[0]));
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method('exec');
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method('addArgument');
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method('readOutput');
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method('kill');
         $mock->expects(\PHPUnit_Framework_TestCase::never())->method('readExecutionState');
     }
     return $mock;
 }
Пример #4
0
 public function expectsNoCall($method)
 {
     return $this->expects($method, $this->testCase->never());
 }