public function testTestInvalidConfigThrowsException() { try { $config = new FromArray($this->invalidConfigPath); $this->assertEquals(2, count($config->getArrayWhereKeysBeginWith('person.'))); } catch (\Exception $e) { $this->assertContains('Config not found', $e->getMessage()); return; } $this->fail('Expected invalid config.'); }
/** * Load and assign the config files from the packages and * the main /res/config.php file */ private function loadConfig() { $cacheName = $this->mode . '_Phavour_Application_config'; if (false != ($configs = $this->cache->get($cacheName))) { // @codeCoverageIgnoreStart $this->config = $configs; return; // @codeCoverageIgnoreEnd } $config = array(); foreach ($this->packagesMetadata as $package) { try { $finder = new FromArray($package['config_path']); $proposedConfig = $finder->getArrayWhereKeysBeginWith($package['package_name']); if (is_array($proposedConfig)) { $config = array_merge($config, $proposedConfig); } } catch (\Exception $e) { // Package doesn't have config } } try { $finder = new FromArray($this->appDirectory . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'config.php'); $appConfig = $finder->getArray(); if (is_array($appConfig)) { $config = array_merge($config, $appConfig); } } catch (\Exception $e) { // No config overrides set } $this->config = $config; $this->cache->set($cacheName, $this->config, 86400); }