예제 #1
0
 /**
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @param \Zend\StdLib\RequestInterface                $request
  * @param \Phpro\SmartCrud\Controller\CrudController   $controller
  * @param \Zend\Mvc\Controller\Plugin\Params           $params
  */
 protected function mockServiceLocator($serviceLocator, $request, $controller, $params)
 {
     $prophet = new Prophet();
     $app = $prophet->prophesize('\\Zend\\Mvc\\Application');
     $event = $prophet->prophesize('\\Zend\\Mvc\\MvcEvent');
     if ($controller) {
         $controller->plugin('params')->willReturn($params->getWrappedObject());
         $controller = $controller->getWrappedObject();
     }
     // mock routeMatch
     $routeMatch = $prophet->prophesize('Zend\\Mvc\\Router\\Http\\RouteMatch');
     $routeMatch->getParam('controller')->willReturn('DummyControllerSlag');
     // Mock controller manager
     $controllerManager = $prophet->prophesize('Zend\\Mvc\\Controller\\ControllerManager');
     $controllerManager->get('DummyControllerSlag')->willReturn($controller);
     $serviceLocator->get('controllerLoader')->willReturn($controllerManager);
     // Add application data to mvc event
     $event->getRequest()->willReturn($request->getWrappedObject());
     $event->getRouteMatch()->willReturn($routeMatch);
     $app->getMvcEvent()->willReturn($event);
     $serviceLocator->get('application')->willReturn($app);
 }