mirror of
https://github.com/Mibew/design.git
synced 2025-05-19 00:34:22 +03:00
77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
|
|
|
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/plugin_manager.php';
|
|
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/plugin.php';
|
|
|
|
/**
|
|
* Test class for PluginManager.
|
|
* Generated by PHPUnit on 2012-07-17 at 16:09:18.
|
|
*/
|
|
class PluginManagerTest extends PHPUnit_Framework_TestCase {
|
|
|
|
public function testLoadPlugins() {
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
|
|
|
|
// Try to load plugin that does not exists
|
|
// Following code wait for trigger user error, which converts by PHPUnit to an
|
|
// Exception
|
|
try {
|
|
PluginManager::loadPlugins(
|
|
array(
|
|
array(
|
|
'name' => 'missed_plugin'
|
|
)
|
|
)
|
|
);
|
|
$this->fail("Exception must be thrown");
|
|
} catch(Exception $e) {}
|
|
|
|
// Try to load plugin with an absent plugin in dependences list
|
|
// Following code wait for trigger user warning, which converts by PHPUnit to an
|
|
// Exception
|
|
try {
|
|
PluginManager::loadPlugins(
|
|
array(
|
|
array(
|
|
'name' => 'phpunit_autotest_plugin_manager',
|
|
'dependences' => array('missed_plugin')
|
|
)
|
|
)
|
|
);
|
|
$this->fail("Exception must be thrown");
|
|
} catch(Exception $e) {}
|
|
|
|
// Try to load correct plugin
|
|
PluginManager::loadPlugins(
|
|
array(
|
|
array(
|
|
'name' => 'phpunit_autotest_plugin_manager'
|
|
)
|
|
)
|
|
);
|
|
|
|
// Check if plugin initialized correctry
|
|
if(empty($GLOBALS['phpunit_autotest_plugin_manager'])) {
|
|
$this->fail('Plugin not loaded and initialize correctly');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @depends testLoadPlugins
|
|
*/
|
|
public function testGetPlugin() {
|
|
// Try to get plugin with wrong name
|
|
// Following code wait for trigger user warning, which converts by PHPUnit to an
|
|
// Exception
|
|
try {
|
|
PluginManager::getPlugin('wrong_plugin_name');
|
|
$this->fail("Exception must be thrown");
|
|
} catch(Exception $e) {}
|
|
|
|
// Try to get loaded plugin
|
|
PluginManager::getPlugin('phpunit_autotest_plugin_manager');
|
|
}
|
|
}
|
|
|
|
?>
|