Exemplo n.º 1
0
 /**
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 public function getParamsMock()
 {
     $mockBuilder = new MockBuilder($this->testCase, 'Zend\\Mvc\\Controller\\Plugin\\Params');
     $mockBuilder->setMethods(['__invoke']);
     $mockBuilder->disableOriginalConstructor();
     $paramsMock = $mockBuilder->getMock();
     $count = 0;
     $params = func_get_args();
     foreach ($params as $param) {
         $paramsMock->expects($this->testCase->at($count++))->method('__invoke')->willReturn($param);
     }
     return $paramsMock;
 }
Exemplo n.º 2
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());
     }
 }
Exemplo n.º 3
0
/**
 * Returns a matcher that matches when the method it is evaluated for
 * is invoked at the given $index.
 *
 * @param  integer $index
 * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
 * @since  Method available since Release 3.0.0
 */
function at($index)
{
    return PHPUnit_Framework_TestCase::at($index);
}
Exemplo n.º 4
0
 public function expectsCallAt($index, $method)
 {
     return $this->expects($method, $this->testCase->at($index));
 }