Added PluginManager::unregisterAll() (#3156)

This commit is contained in:
Harmen Janssen 2017-10-08 20:14:17 +02:00 committed by Luke Towers
parent dcfe59b807
commit a2a91a38e6
2 changed files with 21 additions and 1 deletions

View File

@ -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

View File

@ -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());
}
}