From 600fbd7cfa272749ee21cd9740452cc8ce330142 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Thu, 2 Apr 2020 10:33:58 -0400 Subject: [PATCH] Improve code readability for exists method (#5022) --- modules/system/classes/PluginManager.php | 2 +- tests/unit/system/classes/PluginManagerTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 26e38c10d..1d6c0aa10 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -338,7 +338,7 @@ class PluginManager */ public function exists($id) { - return !(!$this->findByIdentifier($id) || $this->isDisabled($id)); + return $this->findByIdentifier($id) && !$this->isDisabled($id); } /** diff --git a/tests/unit/system/classes/PluginManagerTest.php b/tests/unit/system/classes/PluginManagerTest.php index 6c18dae25..4b20f8509 100644 --- a/tests/unit/system/classes/PluginManagerTest.php +++ b/tests/unit/system/classes/PluginManagerTest.php @@ -225,4 +225,19 @@ class PluginManagerTest extends TestCase $result = $this->manager->isDisabled('dependencytest.notfound'); $this->assertTrue($result); } + + public function testExists() + { + $result = $this->manager->exists('DependencyTest.Found'); + $this->assertTrue($result); + + $result = $this->manager->exists('DependencyTest.WrongCase'); + $this->assertTrue($result); + + $result = $this->manager->exists('DependencyTest.NotFound'); + $this->assertFalse($result); + + $result = $this->manager->exists('Unknown.Plugin'); + $this->assertFalse($result); + } }