@@ -306,15 +306,11 @@ public function testEnvVariablesSubstitution(): void
306
306
* @throws FileSystemException
307
307
* @throws RuntimeException
308
308
*/
309
- public function testReloadDataOnMissingConfig (): void
309
+ public function testShouldntReloadDataOnMissingConfig (): void
310
310
{
311
- $ this ->readerMock ->expects ($ this ->exactly ( 2 ))
311
+ $ this ->readerMock ->expects ($ this ->once ( ))
312
312
->method ('load ' )
313
- ->willReturnOnConsecutiveCalls (
314
- ['db ' => ['connection ' => ['default ' => ['host ' => 'localhost ' ]]]],
315
- [],
316
- []
317
- );
313
+ ->willReturn (['db ' => ['connection ' => ['default ' => ['host ' => 'localhost ' ]]]]);
318
314
$ connectionConfig1 = $ this ->deploymentConfig ->get (
319
315
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/ ' . 'default '
320
316
);
@@ -330,4 +326,39 @@ public function testReloadDataOnMissingConfig(): void
330
326
$ result3 = $ this ->deploymentConfig ->get ('missing/key ' );
331
327
$ this ->assertNull ($ result3 );
332
328
}
329
+
330
+ /**
331
+ * @return void
332
+ */
333
+ public function testShouldntLoadMultipleTimes () : void
334
+ {
335
+ $ this ->readerMock ->expects ($ this ->once ())->method ('load ' )
336
+ ->willReturn (['a ' => ['a ' => ['a ' => 1 ]]]);
337
+ $ this ->deploymentConfig ->get ('a/a/a ' );
338
+ $ this ->deploymentConfig ->get ('a/a/b ' );
339
+ $ this ->deploymentConfig ->get ('a/a/c ' );
340
+ $ this ->deploymentConfig ->get ('a/b/a ' );
341
+ $ this ->deploymentConfig ->get ('a/b/b ' );
342
+ $ this ->deploymentConfig ->get ('a/b/c ' );
343
+ }
344
+
345
+ /**
346
+ * @return void
347
+ */
348
+ public function testShouldReloadPreviouslyUnsetKeysAfterReset () : void
349
+ {
350
+ $ testValue = 42 ;
351
+ $ loadReturn = ['a ' => ['a ' => ['a ' => 1 ]]];
352
+ $ this ->readerMock ->expects ($ this ->any ())->method ('load ' )
353
+ ->will ($ this ->returnCallback (function () use (&$ loadReturn ) { return $ loadReturn ;}));
354
+ $ this ->deploymentConfig ->get ('a/a/a ' );
355
+ $ abcReturnValue1 = $ this ->deploymentConfig ->get ('a/b/c ' );
356
+ $ this ->assertNull ($ abcReturnValue1 ); // first try, it isn't set yet.
357
+ $ loadReturn = ['a ' => ['a ' => ['a ' => 1 ], 'b ' => ['c ' => $ testValue ]]];
358
+ $ this ->deploymentConfig ->resetData ();
359
+ $ this ->deploymentConfig ->get ('a/a/a ' );
360
+ $ abcReturnValue2 = $ this ->deploymentConfig ->get ('a/b/c ' );
361
+ $ this ->assertEquals ($ testValue , $ abcReturnValue2 ); // second try, it should load the newly set value
362
+ }
363
+
333
364
}
0 commit comments