public function testInit() { $this->assertEquals('fooEnv', $this->serverContext->getEnvironment()); $this->assertEquals('fooApp', $this->serverContext->getApplication()); $this->assertEquals($this->rootPath . '/src', $this->serverContext->getPath(ServerContext::DIR_SRC)); $this->assertEquals($this->rootPath . '/action', $this->serverContext->getPath(ServerContext::DIR_ACTIONS)); $this->assertEquals($this->rootPath . '/config', $this->serverContext->getPath(ServerContext::DIR_CONFIG)); $this->assertEquals($this->rootPath . '/public', $this->serverContext->getPath(ServerContext::DIR_PUBLIC)); }
/** * @return ConfigCollection * @throws KernelPanicException If configs dir cannot be read */ public function getConfigCollection() { if (!$this->configCollection) { $configDir = $this->serverContext->getPath(ServerContext::DIR_CONFIG); if (!is_dir($configDir)) { throw new KernelPanicException(sprintf('Config dir does not exists or not readable: %s', $configDir)); } $loader = new YamlFileLoader(new FileLocator([$configDir, $configDir . '/' . $this->serverContext->getEnvironment()])); $this->configCollection = new ConfigCollection(new Factory($loader, Config::class)); $this->configCollection->load(self::CONFIG_SECTION); } return $this->configCollection; }
public function testGetEnvironment() { $this->assertEquals(ServerContext::DEFAULT_ENV, $this->serverContext->getEnvironment()); $this->serverContext->set('ENV', 'foo'); $this->assertEquals('foo', $this->serverContext->getEnvironment()); }