From e3aa0ff63a348668a63f2c90a5df7f276f3c4c54 Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Wed, 3 Jul 2019 10:32:41 -0300 Subject: [PATCH] Added unit tests for config condition if PHP extension is loaded --- .../php/Core/Manifest/ConfigManifestTest.php | 17 +++++++++++ .../mysite/_config/extloadedrules.yml | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/php/Core/Manifest/fixtures/configmanifest/mysite/_config/extloadedrules.yml diff --git a/tests/php/Core/Manifest/ConfigManifestTest.php b/tests/php/Core/Manifest/ConfigManifestTest.php index d12e54883..b6fda78dd 100644 --- a/tests/php/Core/Manifest/ConfigManifestTest.php +++ b/tests/php/Core/Manifest/ConfigManifestTest.php @@ -225,4 +225,21 @@ class ConfigManifestTest extends SapphireTest 'Fragment is included if both blocks succeed.' ); } + + public function testExtensionLoaded() + { + $config = $this->getConfigFixtureValue('ExtensionLoaded'); + + $this->assertEquals( + 'Yes', + @$config['SessionExtLoaded'], + 'Only rule correctly detects loaded PHP extension' + ); + + $this->assertEquals( + 'No', + @$config['DummyExtLoaded'], + 'Except rule correctly detects not-loaded PHP extension' + ); + } } diff --git a/tests/php/Core/Manifest/fixtures/configmanifest/mysite/_config/extloadedrules.yml b/tests/php/Core/Manifest/fixtures/configmanifest/mysite/_config/extloadedrules.yml new file mode 100644 index 000000000..67f6620ef --- /dev/null +++ b/tests/php/Core/Manifest/fixtures/configmanifest/mysite/_config/extloadedrules.yml @@ -0,0 +1,28 @@ +--- +Only: + extensionloaded: "session" +--- +SilverStripe\Core\Tests\Manifest\ConfigManifestTest: + ExtensionLoaded: + SessionExtLoaded: Yes +--- +Only: + extensionloaded: "silverstripe_ext" +--- +SilverStripe\Core\Tests\Manifest\ConfigManifestTest: + ExtensionLoaded: + DummyExtLoaded: Yes +--- +Except: + extensionloaded: "session" +--- +SilverStripe\Core\Tests\Manifest\ConfigManifestTest: + ExtensionLoaded: + SessionExtLoaded: No +--- +Except: + extensionloaded: "silverstripe_ext" +--- +SilverStripe\Core\Tests\Manifest\ConfigManifestTest: + ExtensionLoaded: + DummyExtLoaded: No