Beispiel #1
0
 public function testGetController()
 {
     Nano::setApplication(null);
     $application = new \Nano\Application();
     $application->withConfigurationFormat('php')->withRootDir($this->files->get($this, ''))->configure();
     $c = $application->dispatcher->getController(\Nano\Route\Common::create('', 'test', 'test'));
     self::assertInstanceOf('\\Nano\\Controller', $c);
     self::assertInstanceOf('App\\Controller\\Test', $c);
 }
Beispiel #2
0
 /**
  * @return \Nano\Route\Section\Common
  * @param string $method
  * @param string $location
  * @param string $controller
  * @param string $action
  * @param array $params
  */
 public function add($method, $location, $controller = 'index', $action = 'index', array $params = array())
 {
     $this->addRoute($method, \Nano\Route\Common::create($this->buildLocation($location), $controller, $action, $this->module, $params));
     return $this;
 }
Beispiel #3
0
 public function testGetControllerShouldThrowWhenAbstractClassRequired()
 {
     $this->setExpectedException('\\Nano\\Exception\\InternalError', 'Not a controller class: App\\Controller\\AbstractController');
     require_once __DIR__ . '/_files/controllers/AbstractController.php';
     $this->dispatcher->getController(\Nano\Route\Common::create('', 'abstract-controller', 'test'));
 }
Beispiel #4
0
 public function testParamsShouldPassedIntoRoute()
 {
     $params = \Nano\Route\Common::create('', 'index', 'index', null, array('param' => 'value'))->params();
     self::assertArrayHasKey('param', $params);
     self::assertEquals('value', $params['param']);
 }
Beispiel #5
0
 public function testModuleViews()
 {
     $this->application->withConfigurationFormat('php')->withRootDir(__DIR__ . '/_files')->withModule('test', $this->files->get($this, '/test'))->configure();
     self::assertTrue($this->application->loader->loadClass('Module\\Test\\Controller\\Class1'));
     $response = new \Nano\Controller\Response\Test($this->application);
     $this->application->dispatcher->setResponse($response);
     $this->application->dispatcher->run(\Nano\Route\Common::create('', 'class1', 'view', 'test'));
     self::assertEquals('view action runned', $response->getBody());
 }
Beispiel #6
0
 /**
  * @return void
  * @param \Nano\Route\Common $route
  */
 protected function setUpController(\Nano\Route\Common $route)
 {
     $this->action = $route->action();
     $this->controller = $route->controller();
     $this->module = $route->module();
 }