Beispiel #1
0
 public function testPluginWithoutControllerLocatorRaisesDomainException()
 {
     $controller = new SampleController();
     $plugin = $controller->plugin('forward');
     $this->setExpectedException('Zend\\Mvc\\Exception\\DomainException', 'composes Locator');
     $plugin->dispatch('forward');
 }
 public function testInjectControllerDependenciesWillNotOverwriteExistingEventManager()
 {
     $events = new EventManager();
     $controller = new TestAsset\SampleController();
     $controller->setEventManager($events);
     $this->controllers->injectControllerDependencies($controller, $this->controllers);
     $this->assertSame($events, $controller->getEventManager());
     $this->assertSame($this->sharedEvents, $events->getSharedManager());
 }
Beispiel #3
0
 public function testPluginWithoutRouterInEventRaisesDomainException()
 {
     $controller = new SampleController();
     $event      = new MvcEvent();
     $controller->setEvent($event);
     $plugin = $controller->plugin('url');
     $this->setExpectedException('Zend\Mvc\Exception\DomainException', 'event compose a router');
     $plugin->fromRoute('home');
 }
Beispiel #4
0
 public function testRedirectToRouteWithoutRouterInEventRaisesDomainException()
 {
     $controller = new SampleController();
     $event = new MvcEvent();
     $event->setResponse($this->response);
     $controller->setEvent($event);
     $plugin = $controller->plugin('redirect');
     $this->setExpectedException('Zend\\Mvc\\Exception\\DomainException', 'event compose a router');
     $plugin->toRoute('home');
 }
Beispiel #5
0
 public function testRouteMatchObjectRemainsSameFollowingForwardDispatch()
 {
     $routeMatch = $this->controller->getEvent()->getRouteMatch();
     $matchParams = $routeMatch->getParams();
     $matchMatchedRouteName = $routeMatch->getMatchedRouteName();
     $result = $this->plugin->dispatch('forward', array('action' => 'test-matches', 'param1' => 'foobar'));
     $testMatch = $this->controller->getEvent()->getRouteMatch();
     $testParams = $testMatch->getParams();
     $testMatchedRouteName = $testMatch->getMatchedRouteName();
     $this->assertSame($routeMatch, $testMatch);
     $this->assertEquals($matchParams, $testParams);
     $this->assertEquals($matchMatchedRouteName, $testMatchedRouteName);
 }
Beispiel #6
0
 public function testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters()
 {
     $router = new \Zend\Mvc\Router\Http\TreeRouteStack();
     $router->addRoute('default', array('type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => array('route' => '/:controller/:action', 'defaults' => array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'SampleController', 'action' => 'Dash')), 'child_routes' => array('wildcard' => array('type' => 'Zend\\Mvc\\Router\\Http\\Wildcard', 'options' => array('param_delimiter' => '=', 'key_value_delimiter' => '%')))));
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'Rainbow'));
     $routeMatch->setMatchedRouteName('default/wildcard');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $controller = new SampleController();
     $controller->setEvent($event);
     $url = $controller->plugin('url')->fromRoute('default/wildcard', array('Twenty' => 'Cooler'), true);
     $this->assertEquals('/Rainbow/Dash=Twenty%Cooler', $url);
 }
Beispiel #7
0
 public function testPluginWithoutControllerLocatorRaisesServiceNotCreatedException()
 {
     $controller = new SampleController();
     $this->setExpectedException('Zend\\ServiceManager\\Exception\\ServiceNotCreatedException');
     $plugin = $controller->plugin('forward');
 }