コード例 #1
0
ファイル: Application.php プロジェクト: visor/nano
 /**
  * @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;
 }
コード例 #2
0
ファイル: NamesTest.php プロジェクト: visor/nano
 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'));
 }
コード例 #3
0
 protected function setUp()
 {
     $this->app->backup();
     Nano::setApplication($GLOBALS['application']);
     require_once __DIR__ . '/_files/PublicErrorHandler.php';
     require_once __DIR__ . '/_files/AbstractResponseModifier.php';
     $this->reloadConfig();
 }
コード例 #4
0
ファイル: App.php プロジェクト: visor/nano
 public function restore()
 {
     if (null === $this->backup) {
         return;
     }
     \Nano::setApplication(null);
     \Nano::setApplication($this->backup);
     $this->backup = null;
 }
コード例 #5
0
ファイル: DispatcherTest.php プロジェクト: visor/nano
 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);
 }
コード例 #6
0
ファイル: NanoTest.php プロジェクト: visor/nano
 public function testAppShouldReturnStoredValue()
 {
     self::assertNull(Nano::app());
     Nano::setApplication($GLOBALS['application']);
     self::assertSame($GLOBALS['application'], Nano::app());
 }
コード例 #7
0
ファイル: ScriptInfoTest.php プロジェクト: visor/nano
 public function testStopUsage()
 {
     Nano::setApplication(null);
     self::assertEquals(200, $this->cli->run(array('no-description')));
     self::assertContains('[script stop message]', $this->getActualOutput());
 }
コード例 #8
0
ファイル: LoaderTest.php プロジェクト: visor/nano
 protected function setUp()
 {
     parent::setUp();
     \Nano::setApplication($this->application);
     $this->includePath = get_include_path();
 }
コード例 #9
0
ファイル: CommonTest.php プロジェクト: visor/nano
 public function testRunWrapper()
 {
     Nano::setApplication(null);
     self::assertEquals(0, \Nano\Cli::main(array()));
 }
コード例 #10
0
ファイル: ModulesTest.php プロジェクト: visor/nano
 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());
 }
コード例 #11
0
ファイル: AppTest.php プロジェクト: visor/nano
 protected function tearDown()
 {
     \Nano::setApplication(null);
     \Nano::setApplication($this->app);
 }