public function testDoesNotInjectTemplateWhenInModuleNamespace()
 {
     $e = new \Zend\Mvc\MvcEvent();
     $routerFactory = new \Zend\Mvc\Service\RouterFactory();
     $routeMatch = new \Zend\Mvc\Router\Http\RouteMatch(array('__NAMESPACE__' => 'App\\Controller', 'controller' => 'Index', 'action' => 'index'));
     $routeMatch->setMatchedRouteName('test');
     $e->setRouteMatch($routeMatch)->setController('Index')->setControllerClass('App\\Controller\\Index')->setTarget('App\\Controller\\Index')->setResult(new \Zend\View\Model\ViewModel());
     $this->listener->injectTemplate($e);
     $this->assertEquals('', $e->getResult()->getTemplate());
 }
Exemplo n.º 2
0
 public function testAddBodyClass()
 {
     $bodyClassHelper = new BodyClass();
     $listener = new BodyClassListener($bodyClassHelper);
     $routeMatch = new RouteMatch([]);
     $routeMatch->setMatchedRouteName('my/SOME/route');
     $event = new \Zend\Mvc\MvcEvent();
     $event->setRouteMatch($routeMatch);
     $listener->addBodyClass($event);
     $this->assertEquals('my-some-route', (string) $bodyClassHelper);
 }
Exemplo n.º 3
0
 public function getServiceConfig()
 {
     return array('factories' => array('MaglLegacyApplicationOptions' => function ($sl) {
         $config = $sl->get('Config');
         $options = $config['magl_legacy_application'];
         return new Options\LegacyControllerOptions($options);
     }, 'MaglControllerService' => function (ServiceManager $sl) {
         $eventManager = $sl->get('Application')->getEventManager();
         $event = new \Zend\Mvc\MvcEvent();
         $event->setApplication($sl->get('Application'));
         $event->setTarget($sl->get('Application'));
         $event->setRequest($sl->get('Request'));
         $event->setRouter($sl->get('Router'));
         $event->setRouteMatch(new RouteMatch(array()));
         return new Service\ControllerService($eventManager, $event);
     }));
 }
Exemplo n.º 4
0
 /**
  * Get an initialized instance of the controller plugin
  *
  * If controller setup is requested, the controller will be a
  * \Library\Test\Mvc\Controller\TestController. Its MvcEvent will be
  * initialized with a standard route 'test' (/module/controller/action/)
  * with defaults of "defaultcontroller" and "defaultaction".
  * The RouteMatch is initialized with "currentcontroller" and
  * "currentaction". An empty response is created.
  *
  * @param bool $setController Initialize the helper with a working controller (default: TRUE)
  * @return \Zend\Mvc\Controller\Plugin\PluginInterface Plugin instance
  */
 protected function _getPlugin($setController = true)
 {
     if ($setController) {
         $router = new \Zend\Mvc\Router\Http\TreeRouteStack();
         $router->addRoute('test', \Zend\Mvc\Router\Http\Segment::factory(array('route' => '/[module[/]][:controller[/][:action[/]]]', 'defaults' => array('controller' => 'defaultcontroller', 'action' => 'defaultaction'))));
         $routeMatch = new \Zend\Mvc\Router\RouteMatch(array('controller' => 'currentcontroller', 'action' => 'currentaction'));
         $routeMatch->setMatchedRouteName('test');
         $event = new \Zend\Mvc\MvcEvent();
         $event->setRouter($router);
         $event->setRouteMatch($routeMatch);
         $event->setResponse(new \Zend\Http\Response());
         // Register TestController with the service manager because this is
         // not done in the module setup
         $manager = Application::getService('ControllerManager');
         $manager->setInvokableClass('test', 'Library\\Test\\Mvc\\Controller\\TestController');
         $this->_controller = $manager->get('test');
         $this->_controller->setEvent($event);
         return $this->_controller->plugin($this->_getPluginName());
     } else {
         return $this->_getPluginManager()->get($this->_getPluginName());
     }
 }
Exemplo n.º 5
0
 /**
  * Get an initialized instance of the controller plugin
  *
  * If controller setup is requested, the controller will be a
  * \Zend\Mvc\Controller\AbstractActionController mock. Its MvcEvent will be
  * initialized with a standard route 'test' (/module/controller/action/)
  * with defaults of "defaultcontroller" and "defaultaction".
  * The RouteMatch is initialized with "currentcontroller" and
  * "currentaction". An empty response is created.
  *
  * @param bool $setController Initialize the helper with a working controller (default: TRUE)
  * @return \Zend\Mvc\Controller\Plugin\PluginInterface Plugin instance
  */
 protected function _getPlugin($setController = true)
 {
     if ($setController) {
         $router = new \Zend\Router\Http\TreeRouteStack();
         $router->addRoute('test', \Zend\Router\Http\Segment::factory(array('route' => '/[module[/]][:controller[/][:action[/]]]', 'defaults' => array('controller' => 'defaultcontroller', 'action' => 'defaultaction'))));
         $routeMatch = new \Zend\Router\RouteMatch(array('controller' => 'currentcontroller', 'action' => 'currentaction'));
         $routeMatch->setMatchedRouteName('test');
         $event = new \Zend\Mvc\MvcEvent();
         $event->setRouter($router);
         $event->setRouteMatch($routeMatch);
         $event->setResponse(new \Zend\Http\Response());
         $this->_controller = $this->getMockBuilder('Zend\\Mvc\\Controller\\AbstractActionController')->setMethods(null)->getMockForAbstractClass();
         $this->_controller->setPluginManager($this->_getPluginManager());
         $this->_controller->setEvent($event);
         return $this->_controller->plugin($this->_getPluginName());
     } else {
         return $this->_getPluginManager()->get($this->_getPluginName());
     }
 }