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); }
/** * @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; }
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')); }
public function testParamsShouldPassedIntoRoute() { $params = \Nano\Route\Common::create('', 'index', 'index', null, array('param' => 'value'))->params(); self::assertArrayHasKey('param', $params); self::assertEquals('value', $params['param']); }
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()); }
/** * @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(); }