示例#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);
 }
示例#2
0
文件: Common.php 项目: visor/nano
 /**
  * @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;
 }
示例#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'));
 }
示例#4
0
文件: CommonTest.php 项目: visor/nano
 public function testParamsShouldPassedIntoRoute()
 {
     $params = \Nano\Route\Common::create('', 'index', 'index', null, array('param' => 'value'))->params();
     self::assertArrayHasKey('param', $params);
     self::assertEquals('value', $params['param']);
 }
示例#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());
 }
示例#6
0
文件: Dispatcher.php 项目: visor/nano
 /**
  * @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();
 }