diff options
-rw-r--r-- | application/config/ConfigPhp.php | 6 | ||||
-rw-r--r-- | tests/config/ConfigPhpTest.php | 14 | ||||
-rw-r--r-- | tests/utils/config/emptyConfigPhp.php | 1 |
3 files changed, 18 insertions, 3 deletions
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index 2f66e8e0..8add8bcd 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php | |||
@@ -83,10 +83,10 @@ class ConfigPhp implements ConfigIO | |||
83 | 83 | ||
84 | $out = array(); | 84 | $out = array(); |
85 | foreach (self::$ROOT_KEYS as $key) { | 85 | foreach (self::$ROOT_KEYS as $key) { |
86 | $out[$key] = $GLOBALS[$key]; | 86 | $out[$key] = isset($GLOBALS[$key]) ? $GLOBALS[$key] : ''; |
87 | } | 87 | } |
88 | $out['config'] = $GLOBALS['config']; | 88 | $out['config'] = isset($GLOBALS['config']) ? $GLOBALS['config'] : []; |
89 | $out['plugins'] = !empty($GLOBALS['plugins']) ? $GLOBALS['plugins'] : array(); | 89 | $out['plugins'] = isset($GLOBALS['plugins']) ? $GLOBALS['plugins'] : []; |
90 | return $out; | 90 | return $out; |
91 | } | 91 | } |
92 | 92 | ||
diff --git a/tests/config/ConfigPhpTest.php b/tests/config/ConfigPhpTest.php index abfbb305..be23eea1 100644 --- a/tests/config/ConfigPhpTest.php +++ b/tests/config/ConfigPhpTest.php | |||
@@ -37,6 +37,20 @@ class ConfigPhpTest extends \PHPUnit_Framework_TestCase | |||
37 | } | 37 | } |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Read an empty existent config file -> array with blank default values. | ||
41 | */ | ||
42 | public function testReadEmpty() | ||
43 | { | ||
44 | $dataFile = 'tests/utils/config/emptyConfigPhp.php'; | ||
45 | $conf = $this->configIO->read($dataFile); | ||
46 | $this->assertEmpty($conf['login']); | ||
47 | $this->assertEmpty($conf['title']); | ||
48 | $this->assertEmpty($conf['titleLink']); | ||
49 | $this->assertEmpty($conf['config']); | ||
50 | $this->assertEmpty($conf['plugins']); | ||
51 | } | ||
52 | |||
53 | /** | ||
40 | * Write a new config file. | 54 | * Write a new config file. |
41 | */ | 55 | */ |
42 | public function testWriteNew() | 56 | public function testWriteNew() |
diff --git a/tests/utils/config/emptyConfigPhp.php b/tests/utils/config/emptyConfigPhp.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/tests/utils/config/emptyConfigPhp.php | |||
@@ -0,0 +1 @@ | |||
<?php | |||