protected function loadLanguage() { // Running unit tests? if (defined('LINFO_TESTING')) { $this->lang = LinfoCommon::getVarFromFile(LINFO_TESTDIR . '/test_lang.php', 'lang'); if (!is_array($this->lang)) { throw new LinfoFatalException('Failed getting test-specific language'); } return; } // Load translation, defaulting to english of keys are missing (assuming // we're not using english anyway and the english translation indeed exists) if (is_file(LINFO_LOCAL_PATH . 'lang/en.php') && $this->settings['language'] != 'en') { $this->lang = array_merge(LinfoCommon::getVarFromFile(LINFO_LOCAL_PATH . 'lang/en.php', 'lang'), LinfoCommon::getVarFromFile(LINFO_LOCAL_PATH . 'lang/' . $this->settings['language'] . '.php', 'lang')); } else { $this->lang = LinfoCommon::getVarFromFile(LINFO_LOCAL_PATH . 'lang/' . $this->settings['language'] . '.php', 'lang'); } }
/** * @test */ public function getVarFromFile() { $file = LINFO_TESTDIR . '/files/varfile.php'; $this->assertEquals('foo', LinfoCommon::getVarFromFile($file, 'var')); }