/** * @return \Nano\Application * * @throws \Nano\Application\Exception\InvalidConfiguration */ public function configure() { if (!$this->offsetExists('configFormat')) { throw new Application\Exception\InvalidConfiguration('Configuration format not specified'); } \Nano::setApplication($this); if (!$this->offsetExists('rootDir')) { $this->withRootDir(getCwd()); } if (!$this->offsetExists('publicDir')) { $this->withPublicDir($this->rootDir . DIRECTORY_SEPARATOR . self::PUBLIC_DIR_NAME); } if (!$this->offsetExists('modulesDir')) { $this->withModulesDir($this->rootDir . DIRECTORY_SEPARATOR . self::MODULES_DIR_NAME); } if (!$this->offsetExists('sharedModulesDir')) { $this->withSharedModulesDir($this->nanoRootDir . DIRECTORY_SEPARATOR . self::MODULES_DIR_NAME); } if ('cli' !== php_sapi_name()) { $this->errorHandler = new Application\ErrorHandler(); } $this->readOnly('config', new Application\Config($this->rootDir . DIRECTORY_SEPARATOR . 'settings', $this->configFormat)); $this->setupErrorReporting(); return $this; }
protected function setUp() { $this->app->backup(); Nano::setApplication($GLOBALS['application']); Nano::app()->withModule('some', $this->files->get($this, '/module1')); Nano::app()->withModule('other', $this->files->get($this, '/module2')); }
protected function setUp() { $this->app->backup(); Nano::setApplication($GLOBALS['application']); require_once __DIR__ . '/_files/PublicErrorHandler.php'; require_once __DIR__ . '/_files/AbstractResponseModifier.php'; $this->reloadConfig(); }
public function restore() { if (null === $this->backup) { return; } \Nano::setApplication(null); \Nano::setApplication($this->backup); $this->backup = null; }
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); }
public function testAppShouldReturnStoredValue() { self::assertNull(Nano::app()); Nano::setApplication($GLOBALS['application']); self::assertSame($GLOBALS['application'], Nano::app()); }
public function testStopUsage() { Nano::setApplication(null); self::assertEquals(200, $this->cli->run(array('no-description'))); self::assertContains('[script stop message]', $this->getActualOutput()); }
protected function setUp() { parent::setUp(); \Nano::setApplication($this->application); $this->includePath = get_include_path(); }
public function testRunWrapper() { Nano::setApplication(null); self::assertEquals(0, \Nano\Cli::main(array())); }
public function testClassesAutoloading() { \Nano::setApplication($this->application); $this->application->withModule('test', $this->files->get($this, '/test')); self::assertTrue(class_exists('Module\\Test\\LibraryClass')); self::assertEquals('Module\\Test\\LibraryClass', \Module\Test\LibraryClass::name()); }
protected function tearDown() { \Nano::setApplication(null); \Nano::setApplication($this->app); }