diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index a6ce922f6..926293ec0 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -162,6 +162,16 @@ class PluginManager $this->registered = true; } + /** + * Unregisters all plugins: the negative of registerAll(). + * @return void + */ + public function unregisterAll() + { + $this->registered = false; + $this->plugins = []; + } + /** * Registers a single plugin object. * @param PluginBase $plugin diff --git a/tests/unit/system/classes/PluginManagerTest.php b/tests/unit/system/classes/PluginManagerTest.php index 3a30196cf..b34817c3f 100644 --- a/tests/unit/system/classes/PluginManagerTest.php +++ b/tests/unit/system/classes/PluginManagerTest.php @@ -122,7 +122,7 @@ class PluginManagerTest extends TestCase $this->assertArrayHasKey('\database\tester', $result); $this->assertArrayHasKey('\testvendor\test', $result); } - + public function testGetVendorAndPluginNames() { $manager = PluginManager::instance(); @@ -149,4 +149,14 @@ class PluginManagerTest extends TestCase $this->assertEquals('Alexey Bobkov, Samuel Georges', $pluginDetails['author']); } + public function testUnregisterall() + { + $manager = PluginManager::instance(); + $result = $manager->getPlugins(); + $this->assertCount(5, $result); + + $manager->unregisterAll(); + $this->assertEmpty($manager->getPlugins()); + } + }