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);
 }
 /**
  * routeFromArray(): defined by SimpleRouteStack.
  *
  * @see    BaseSimpleRouteStack::routeFromArray()
  * @param  array|Traversable $specs
  * @return RouteInterface
  * @throws Exception\InvalidArgumentException
  * @throws Exception\RuntimeException
  */
 protected function routeFromArray($specs)
 {
     if ($specs instanceof Traversable) {
         $specs = ArrayUtils::iteratorToArray($specs);
     }
     if (!is_array($specs)) {
         throw new Exception\InvalidArgumentException('Route definition must be an array or Traversable object');
     }
     // default to 'simple' console route
     if (!isset($specs['type'])) {
         $specs['type'] = Simple::class;
     }
     // build route object
     $route = parent::routeFromArray($specs);
     if (!$route instanceof RouteInterface) {
         throw new Exception\RuntimeException('Given route does not implement Console route interface');
     }
     return $route;
 }
 /**
  * routeFromArray(): defined by SimpleRouteStack.
  *
  * @see    SimpleRouteStack::routeFromArray()
  * @param  string|array|Traversable $specs
  * @return RouteInterface
  * @throws Exception\InvalidArgumentException When route definition is not an array nor traversable
  * @throws Exception\InvalidArgumentException When chain routes are not an array nor traversable
  * @throws Exception\RuntimeException         When a generated routes does not implement the HTTP route interface
  */
 protected function routeFromArray($specs)
 {
     if (is_string($specs)) {
         if (null === ($route = $this->getPrototype($specs))) {
             throw new Exception\RuntimeException(sprintf('Could not find prototype with name %s', $specs));
         }
         return $route;
     } elseif ($specs instanceof Traversable) {
         $specs = ArrayUtils::iteratorToArray($specs);
     } elseif (!is_array($specs)) {
         throw new Exception\InvalidArgumentException('Route definition must be an array or Traversable object');
     }
     if (isset($specs['chain_routes'])) {
         if (!is_array($specs['chain_routes'])) {
             throw new Exception\InvalidArgumentException('Chain routes must be an array or Traversable object');
         }
         $chainRoutes = array_merge([$specs], $specs['chain_routes']);
         unset($chainRoutes[0]['chain_routes']);
         if (isset($specs['child_routes'])) {
             unset($chainRoutes[0]['child_routes']);
         }
         $options = ['routes' => $chainRoutes, 'route_plugins' => $this->routePluginManager, 'prototypes' => $this->prototypes];
         $route = $this->routePluginManager->get('chain', $options);
     } else {
         $route = parent::routeFromArray($specs);
     }
     if (!$route instanceof RouteInterface) {
         throw new Exception\RuntimeException('Given route does not implement HTTP route interface');
     }
     if (isset($specs['child_routes'])) {
         $options = ['route' => $route, 'may_terminate' => isset($specs['may_terminate']) && $specs['may_terminate'], 'child_routes' => $specs['child_routes'], 'route_plugins' => $this->routePluginManager, 'prototypes' => $this->prototypes];
         $priority = isset($route->priority) ? $route->priority : null;
         $route = $this->routePluginManager->get('part', $options);
         $route->priority = $priority;
     }
     return $route;
 }