public function testDetect() { $map = ['local' => [['a' => 1], ['b' => 1, 'c' => 1]], 'tests' => [['d' => 0, 'a' => 1]]]; $values = ['local', 'local', '']; $results = []; $locator = new EnvironmentDetector($map); foreach ($values as $key => $serverInfo) { $this->AssertEquals($results[$key], $locator->detect($serverInfo)); } }
protected function loadEnvironment($environment = null) { if (!$this->loadEnvironment) { return; } // Загружаем загрузчик сайта \Trace::addMessage('CMS', 'init.php loaded'); $initScript = APPLICATION_PATH . '/init.php'; if (file_exists($initScript)) { require_once $initScript; } else { die('Couldn`t locate initial (init.php) script'); } if (is_null($environment)) { $map = (include APPLICATION_PATH . 'environmentMap.php'); $detector = new EnvironmentDetector($map); $environment = $detector->detect($_SERVER); } $this->currentEnvironment = $environment; $path = SYS_ROOT . 'Environment/' . $environment . '/init.php'; if (!file_exists($path)) { throw new \RuntimeException('Unable to load environment: ' . $environment); } require_once $path; }