Example #1
0
 public function testDetectingContextBySuffix()
 {
     Nano::setApplication(null);
     $application = new \Nano\Application();
     $application->withConfigurationFormat('php')->withRootDir($this->files->get($this, ''))->configure();
     $application->dispatcher->setResponse(new \Nano\Controller\Response\Test($application));
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $routes = new \Nano\Routes();
     $routes->suffix('~(\\.(?P<context>xml|rss))?')->get('index', 'test', 'index');
     self::assertInstanceOf('Nano\\Route\\RegExp', $application->dispatcher->getRoute($routes, 'index.xml'));
     $application->dispatcher->run($application->dispatcher->getRoute($routes, 'index.xml'));
     self::assertEquals('xml', $application->dispatcher->controllerInstance()->context);
 }