Hello Everyone,

I am running on the latest version of the ZF 2.2.4

I have the following route:

  'overview'  => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/overview[/productgroup/:productgroup]',
                    'defaults' => array(
                        '__NAMESPACE__' => 'MyApp\Controller',
                        'controller' => 'Overview',
                        'action'    => 'index',
                    ),
                ),
                'may_terminate' => true,
            ),

Now in my controller i want to test that i can acces the overview route


 public function setUp(){

        $serviceManager = ServiceManagerFactory::getServiceManager();
        $this->controller   = new OverviewController();
        $this->request      = new Request();
        $this->routeMatch   = new RouteMatch(array('controller' =>
'overview'));
        $this->event        = new MvcEvent();

        $config = $serviceManager->get('Config');
        $routerConfig = isset($config['router']) ? $config['router'] :
array();
        $router = HttpRouter::factory($routerConfig);

        $this->event->setRouter($router);
        $this->event->setRouteMatch($this->routeMatch);
        $this->controller->setEvent($this->event);
        $this->controller->setServiceLocator($serviceManager);
    }

    public function testIndexActionCanBeAccessed(){
        $this->routeMatch->setParam('action', 'index');

        $response = $this->controller->getResponse();
        $this->assertEquals(200, $response->getStatusCode());
    }

But I get this error:


1) MyAppTest\Controller\OverviewControllerTest::testIndexActionCanBeAccessed
Zend\Mvc\Router\Exception\InvalidArgumentException: Missing "type" option

C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
SimpleRouteStack.php:269
C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
Http\TreeRouteStack.php:159
C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
Http\TreeRouteStack.php:113
C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
SimpleRouteStack.php:140
C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
SimpleRouteStack.php:84
C:\wamp\www\MyApp\vendor\zendframework\zendframework\library\Zend\Mvc\Router\
Http\TreeRouteStack.php:65
C:\wamp\www\MyApp\module\MyApp\test\MyAppTest\Controller\OverviewContro
llerTest.php:45
C:\wamp\bin\php\php5.3.9\pear\PHPUnit\TextUI\Command.php:176
C:\wamp\bin\php\php5.3.9\pear\PHPUnit\TextUI\Command.php:129


The error says that i Miss the type option. But if you look at the route
you see there is a type option. What could be wrong?


Thanks

-- 


Jigal Sanders

Reply via email to