Get environment variables.
public function testConstructWithEnv() { $base = Libraries::get(true, 'resources') . '/tmp/tests'; $this->skipIf(!is_readable($base), "Path `{$base}` is not readable."); chdir(Libraries::get(true, 'resources') . '/tmp'); $request = new Request(array('env' => array('working' => '/some/other/path'))); $expected = '/some/other/path'; $result = $request->env('working'); $this->assertEqual($expected, $result); }
public function testConstructWithEnv() { chdir(LITHIUM_APP_PATH . '/resources/tmp'); $request = new Request(array('env' => array('working' => '/some/other/path'))); $expected = '/some/other/path'; $result = $request->env('working'); $this->assertEqual($expected, $result); }
public function testConstructWithEnv() { $base = LITHIUM_APP_PATH . '/resources/tmp/tests'; $this->skipIf(!is_readable($base), "{$base} is not writable."); chdir(LITHIUM_APP_PATH . '/resources/tmp'); $request = new Request(array('env' => array('working' => '/some/other/path'))); $expected = '/some/other/path'; $result = $request->env('working'); $this->assertEqual($expected, $result); }
/** * Detects preferred locales from a console request by looking at certain * environment variables. The environment variables may be present or not * depending on your system. If multiple variables are present the following * hierarchy is used: `'LANGUAGE'`, `'LC_ALL'`, `'LANG'`. * * The locales of the `'LC_ALL'` and the `'LANG'` are formatted according * to the posix standard: `language(_territory)(.encoding)(@modifier)`. * Locales having such a format are automatically canonicalized and transformed * into the `Locale` class' format. * * @link http://www.linux.com/archive/feature/53781 * @param \lithium\console\Request $request * @return array Preferred locales in their canonical form (i.e. `'fr_CA'`). */ protected static function _preferredConsole($request) { $regex = '(?P<locale>[\\w\\_]+)(\\.|@|$)+'; $result = array(); if ($value = $request->env('LANGUAGE')) { return explode(':', $value); } foreach (array('LC_ALL', 'LANG') as $variable) { $value = $request->env($variable); if (!$value || $value === 'C' || $value === 'POSIX') { continue; } if (preg_match("/{$regex}/", $value, $matches)) { return (array) $matches['locale']; } } return $result; }