3030use function tempnam ;
3131use function unlink ;
3232
33+ use const CONFIG_FILE ;
3334use const DIRECTORY_SEPARATOR ;
3435use const INFO_MODULES ;
3536use const PHP_EOL ;
@@ -56,15 +57,17 @@ protected function setUp(): void
5657 parent ::setTheme ();
5758 $ GLOBALS ['dbi ' ] = $ this ->createDatabaseInterface ();
5859 $ _SERVER ['HTTP_USER_AGENT ' ] = '' ;
59- $ this ->object = new Config ();
60+ $ this ->object = $ this -> createConfig ();
6061 $ GLOBALS ['server ' ] = 0 ;
6162 $ _SESSION ['git_location ' ] = '.git ' ;
6263 $ _SESSION ['is_git_revision ' ] = true ;
63- $ GLOBALS ['config ' ] = new Config (CONFIG_FILE );
64+ $ GLOBALS ['config ' ] = new Config ();
65+ $ GLOBALS ['config ' ]->loadAndCheck (CONFIG_FILE );
6466 $ GLOBALS ['cfg ' ]['ProxyUrl ' ] = '' ;
6567
6668 //for testing file permissions
67- $ this ->permTestObj = new Config (ROOT_PATH . 'config.sample.inc.php ' );
69+ $ this ->permTestObj = new Config ();
70+ $ this ->permTestObj ->loadAndCheck (ROOT_PATH . 'config.sample.inc.php ' );
6871 }
6972
7073 /**
@@ -83,7 +86,7 @@ protected function tearDown(): void
8386 */
8487 public function testLoadConfigs (): void
8588 {
86- $ defaultConfig = new Config ();
89+ $ defaultConfig = $ this -> createConfig ();
8790 $ tmpConfig = tempnam ('./ ' , 'config.test.inc.php ' );
8891 if ($ tmpConfig === false ) {
8992 $ this ->markTestSkipped ('Creating a temporary file does not work ' );
@@ -94,15 +97,17 @@ public function testLoadConfigs(): void
9497 // end of setup
9598
9699 // Test loading an empty file does not change the default config
97- $ config = new Config ($ tmpConfig );
100+ $ config = new Config ();
101+ $ config ->loadAndCheck ($ tmpConfig );
98102 $ this ->assertSame ($ defaultConfig ->settings , $ config ->settings );
99103
100104 $ contents = '<?php ' . PHP_EOL
101105 . '$cfg[ \'ProtectBinary \'] = true; ' ;
102106 file_put_contents ($ tmpConfig , $ contents );
103107
104108 // Test loading a config changes the setup
105- $ config = new Config ($ tmpConfig );
109+ $ config = new Config ();
110+ $ config ->loadAndCheck ($ tmpConfig );
106111 $ defaultConfig ->settings ['ProtectBinary ' ] = true ;
107112 $ this ->assertSame ($ defaultConfig ->settings , $ config ->settings );
108113 $ defaultConfig ->settings ['ProtectBinary ' ] = 'blob ' ;
@@ -117,7 +122,7 @@ public function testLoadConfigs(): void
117122 */
118123 public function testLoadInvalidConfigs (): void
119124 {
120- $ defaultConfig = new Config ();
125+ $ defaultConfig = $ this -> createConfig ();
121126 $ tmpConfig = tempnam ('./ ' , 'config.test.inc.php ' );
122127 if ($ tmpConfig === false ) {
123128 $ this ->markTestSkipped ('Creating a temporary file does not work ' );
@@ -128,15 +133,17 @@ public function testLoadInvalidConfigs(): void
128133 // end of setup
129134
130135 // Test loading an empty file does not change the default config
131- $ config = new Config ($ tmpConfig );
136+ $ config = new Config ();
137+ $ config ->loadAndCheck ($ tmpConfig );
132138 $ this ->assertSame ($ defaultConfig ->settings , $ config ->settings );
133139
134140 $ contents = '<?php ' . PHP_EOL
135141 . '$cfg[ \'fooBar \'] = true; ' ;
136142 file_put_contents ($ tmpConfig , $ contents );
137143
138144 // Test loading a custom key config changes the setup
139- $ config = new Config ($ tmpConfig );
145+ $ config = new Config ();
146+ $ config ->loadAndCheck ($ tmpConfig );
140147 $ defaultConfig ->settings ['fooBar ' ] = true ;
141148 // Equals because of the key sorting
142149 $ this ->assertEquals ($ defaultConfig ->settings , $ config ->settings );
@@ -151,7 +158,8 @@ public function testLoadInvalidConfigs(): void
151158 file_put_contents ($ tmpConfig , $ contents );
152159
153160 // Test loading a custom key config changes the setup
154- $ config = new Config ($ tmpConfig );
161+ $ config = new Config ();
162+ $ config ->loadAndCheck ($ tmpConfig );
155163 $ defaultConfig ->settings ['ValidKey ' ] = true ;
156164 // Equals because of the key sorting
157165 $ this ->assertEquals ($ defaultConfig ->settings , $ config ->settings );
0 commit comments