mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge branch '4.1' into 4
This commit is contained in:
commit
722f2d178a
@ -43,7 +43,13 @@ class Environment
|
|||||||
public static function getVariables()
|
public static function getVariables()
|
||||||
{
|
{
|
||||||
// Suppress return by-ref
|
// Suppress return by-ref
|
||||||
return array_merge($GLOBALS, [ 'env' => static::$env ]);
|
$vars = [ 'env' => static::$env ];
|
||||||
|
// needs to use a for loop, using `array_merge([], $GLOBALS);` left reference traces somehow
|
||||||
|
foreach ($GLOBALS as $varName => $varValue) {
|
||||||
|
$vars[$varName] = $varValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,8 +14,8 @@ if (!defined('BASE_PATH')) {
|
|||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
// Asset folder
|
// Asset folder
|
||||||
if (!file_exists(BASE_PATH . '/assets')) {
|
if (!file_exists(ASSETS_PATH)) {
|
||||||
mkdir(BASE_PATH . '/assets', 02775);
|
mkdir(ASSETS_PATH, 02775);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_SERVER['HTTP_HOST'])) {
|
if (empty($_SERVER['HTTP_HOST'])) {
|
||||||
|
@ -53,4 +53,17 @@ class EnvironmentTest extends SapphireTest
|
|||||||
Environment::setVariables($vars);
|
Environment::setVariables($vars);
|
||||||
$this->assertEquals('initial', Environment::getEnv('_ENVTEST_RESTORED'));
|
$this->assertEquals('initial', Environment::getEnv('_ENVTEST_RESTORED'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetVariables()
|
||||||
|
{
|
||||||
|
$GLOBALS['test'] = 'global';
|
||||||
|
$vars = Environment::getVariables();
|
||||||
|
$this->assertArrayHasKey('test', $vars);
|
||||||
|
$this->assertEquals('global', $vars['test']);
|
||||||
|
$this->assertEquals('global', $GLOBALS['test']);
|
||||||
|
|
||||||
|
$vars['test'] = 'fail';
|
||||||
|
$this->assertEquals('fail', $vars['test']);
|
||||||
|
$this->assertEquals('global', $GLOBALS['test']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user