Merge branch '4.1' into 4

This commit is contained in:
Daniel Hensby 2018-02-26 10:57:52 +00:00
commit 722f2d178a
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
3 changed files with 22 additions and 3 deletions

View File

@ -43,7 +43,13 @@ class Environment
public static function getVariables()
{
// 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;
}
/**

View File

@ -14,8 +14,8 @@ if (!defined('BASE_PATH')) {
ini_set('display_errors', 1);
// Asset folder
if (!file_exists(BASE_PATH . '/assets')) {
mkdir(BASE_PATH . '/assets', 02775);
if (!file_exists(ASSETS_PATH)) {
mkdir(ASSETS_PATH, 02775);
}
if (empty($_SERVER['HTTP_HOST'])) {

View File

@ -53,4 +53,17 @@ class EnvironmentTest extends SapphireTest
Environment::setVariables($vars);
$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']);
}
}