Add PluginManager::getAllPlugins() method

This commit is contained in:
Dmitriy Simushev 2012-10-03 10:14:13 +00:00
parent 30cb668a73
commit 53e9400dde
2 changed files with 27 additions and 0 deletions

View File

@ -71,6 +71,18 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase {
// Try to get loaded plugin // Try to get loaded plugin
PluginManager::getPlugin('phpunit_autotest_plugin_manager'); PluginManager::getPlugin('phpunit_autotest_plugin_manager');
} }
/**
* @depends testGetPlugin
*/
public function testGetAllPlugins() {
// Get loaded plugin
$plugin = PluginManager::getPlugin('phpunit_autotest_plugin_manager');
// Build plugins list to comparison
$plugins_list = array('phpunit_autotest_plugin_manager' => $plugin);
// Check loaded plugins list
$this->assertEquals($plugins_list, PluginManager::getAllPlugins());
}
} }
?> ?>

View File

@ -20,6 +20,10 @@
*/ */
Class PluginManager { Class PluginManager {
/**
* Contains all loaded plugins
* @var array
*/
protected static $loaded_plugins = array(); protected static $loaded_plugins = array();
/** /**
@ -38,6 +42,17 @@ Class PluginManager {
return self::$loaded_plugins[$plugin_name]; return self::$loaded_plugins[$plugin_name];
} }
/**
* Returns associative array of loaded plugins.
*
* Key represents plugin's name and value contains Plugin object
*
* @return array
*/
public static function getAllPlugins() {
return self::$loaded_plugins;
}
/** /**
* Loads plugins and invokes Plugin::registerEvents() and Plugin::registerListeners() * Loads plugins and invokes Plugin::registerEvents() and Plugin::registerListeners()
* *