Merge pull request #1063 from ArthurHoaro/hotfix/legacy-warnings

Fix warnings when upgrading from legacy SebSauvage version
This commit is contained in:
ArthurHoaro 2018-01-31 12:18:31 +01:00 committed by GitHub
commit 2cbf4acdde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -83,10 +83,10 @@ public function read($filepath)
$out = array();
foreach (self::$ROOT_KEYS as $key) {
$out[$key] = $GLOBALS[$key];
$out[$key] = isset($GLOBALS[$key]) ? $GLOBALS[$key] : '';
}
$out['config'] = $GLOBALS['config'];
$out['plugins'] = !empty($GLOBALS['plugins']) ? $GLOBALS['plugins'] : array();
$out['config'] = isset($GLOBALS['config']) ? $GLOBALS['config'] : [];
$out['plugins'] = isset($GLOBALS['plugins']) ? $GLOBALS['plugins'] : [];
return $out;
}

View file

@ -36,6 +36,20 @@ public function testReadNonExistent()
$this->assertEquals(array(), $this->configIO->read('nope'));
}
/**
* Read an empty existent config file -> array with blank default values.
*/
public function testReadEmpty()
{
$dataFile = 'tests/utils/config/emptyConfigPhp.php';
$conf = $this->configIO->read($dataFile);
$this->assertEmpty($conf['login']);
$this->assertEmpty($conf['title']);
$this->assertEmpty($conf['titleLink']);
$this->assertEmpty($conf['config']);
$this->assertEmpty($conf['plugins']);
}
/**
* Write a new config file.
*/

View file

@ -0,0 +1 @@
<?php