From 474506f502558c863a28b6d014a2cc719b266fcf Mon Sep 17 00:00:00 2001 From: Dominic Benson <dominic.benson@thirdlight.com> Date: Wed, 21 Mar 2018 12:10:27 +0000 Subject: [PATCH] Test for preloading Explicitly test a file that does not exist, as well as a preloaded one Virtual test file names intented to be semantic but not collide. --- tests/lib/SimpleSAML/ConfigurationTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index fced577ef..b644f0344 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -925,6 +925,27 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest $c->getLocalizedString('opt'); } + /** + * Test SimpleSAML_Configuration::getConfig() nonexistent file + * @expectedException Exception + */ + public function testGetConfigNonexistentFile() { + SimpleSAML_Configuration::getConfig('nonexistent-nopreload.php'); + } + + /** + * Test SimpleSAML_Configuration::getConfig() preloaded nonexistent file + */ + public function testGetConfigNonexistentFilePreload() { + $c = SimpleSAML_Configuration::loadFromArray(array( + 'key' => 'value' + )); + $virtualFile = 'nonexistent-preload.php'; + SimpleSAML_Configuration::setPreLoadedConfig($c, $virtualFile); + $nc = SimpleSAML_Configuration::getConfig($virtualFile); + $this->assertEquals('value', $nc->getValue('key', null)); + } + /** * Test that Configuration objects can be initialized from an array. * -- GitLab