public function setUp()
 {
     $router = new TreeRouteStack();
     $router->addRoute('home', LiteralRoute::factory(['route' => '/', 'defaults' => ['controller' => TestAsset\SampleController::class]]));
     $router->addRoute('sub', SegmentRoute::factory(['route' => '/foo/:param', 'defaults' => ['param' => 1]]));
     $router->addRoute('ctl', SegmentRoute::factory(['route' => '/ctl/:controller', 'defaults' => ['__NAMESPACE__' => 'ZendTest\\Mvc\\Plugin\\Prg\\TestAsset', 'controller' => 'sample']]));
     $this->controller = new TestAsset\SampleController();
     $this->request = new Request();
     $this->event = new MvcEvent();
     $this->routeMatch = new RouteMatch(['controller' => 'controller-sample', 'action' => 'postPage']);
     $this->event->setRequest($this->request);
     $this->event->setRouteMatch($this->routeMatch);
     $this->event->setRouter($router);
     $this->controller->setEvent($this->event);
     $this->plugin = new PostRedirectGet();
     $this->plugin->setController($this->controller);
 }
 public function setUp()
 {
     $this->form = new Form();
     $this->collection = new Collection('links', ['count' => 1, 'allow_add' => true, 'target_element' => ['type' => TestAsset\LinksFieldset::class]]);
     $router = new SimpleRouteStack();
     $router->addRoute('home', LiteralRoute::factory(['route' => '/', 'defaults' => ['controller' => TestAsset\SampleController::class]]));
     $router->addRoute('sub', SegmentRoute::factory(['route' => '/foo/:param', 'defaults' => ['param' => 1]]));
     $router->addRoute('ctl', SegmentRoute::factory(['route' => '/ctl/:controller', 'defaults' => ['__NAMESPACE__' => 'ZendTest\\Mvc\\Controller\\TestAsset']]));
     $this->controller = new TestAsset\SampleController();
     $this->request = new Request();
     $this->event = new MvcEvent();
     $this->routeMatch = new RouteMatch(['controller' => 'controller-sample', 'action' => 'postPage']);
     $this->event->setRequest($this->request);
     $this->event->setRouteMatch($this->routeMatch);
     $this->event->setRouter($router);
     $this->controller->setEvent($this->event);
     $this->plugin = new FilePostRedirectGet();
     $this->plugin->setController($this->controller);
 }
Esempio n. 3
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());
     }
 }