plugins = new Plugins(); $this->plugins->addComponentPath('test'.DS.'plugins'); $this->plugins->loadHeadersFromPluginPaths(); } /** * @coversNothing */ public function testGetPluginsClass() { $this->assertInstanceOf('FuzeWorks\Plugins', $this->plugins); } /** * @depends testGetPluginsClass * @covers ::get */ public function testLoadPlugin() { $this->assertInstanceOf('\Application\Plugin\TestLoadPlugin', $this->plugins->get('testLoadPlugin')); } /** * @depends testLoadPlugin * @covers ::get */ public function testReloadPlugin() { $this->assertSame($this->plugins->get('testReloadPlugin'), $this->plugins->get('testReloadPlugin')); } /** * @depends testLoadPlugin * @covers ::get */ public function testLoadHeader() { // Load the header object require_once('test' . DS . 'plugins' . DS . 'TestLoadHeader'.DS.'loadHeader'.DS.'header.php'); $header = new Plugins\TestLoadHeaderHeader(); // Register the header object $this->plugins->addPlugin($header); // Assert the plugin $this->assertInstanceOf('Application\Plugin\Plug', $this->plugins->get('Plug')); } /** * @depends testLoadPlugin * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingHeader() { $this->plugins->get('testMissingHeader'); } /** * @depends testLoadPlugin * @covers ::get */ public function testGetPluginMethod() { $this->assertEquals('test_string', $this->plugins->get('testGetPluginMethod')); } /** * @depends testLoadPlugin * @covers ::get */ public function testGetPluginWithClassFile() { $this->assertInstanceOf('OtherPlug', $this->plugins->get('TestGetPluginWithClassFile')); } /** * @depends testLoadPlugin * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingPlugin() { $this->plugins->get('testMissingPlugin'); } /** * @depends testMissingPlugin * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testLoadHeaderNotIPluginHeader() { $this->plugins->get('TestLoadHeaderNotIPluginHeader'); } /** * @depends testLoadPlugin * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testInvalidClass() { $this->plugins->get('testInvalidClass'); } /** * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testGetMissingName() { $this->plugins->get(''); } /** * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths * @expectedException FuzeWorks\Exception\PluginException */ public function testDisabledPlugin() { Factory::getInstance()->config->plugins->disabled_plugins = array('TestDisabledPlugin'); $this->plugins->loadHeadersFromPluginPaths(); $this->plugins->get('testDisabledPlugin'); } /** * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths * @expectedException FuzeWorks\Exception\PluginException */ public function testRunInvalidDirectory() { $this->plugins->addComponentPath('exists_not'); $this->plugins->loadHeadersFromPluginPaths(); $this->plugins->get('testRunInvalidDirectory'); } public function tearDown() { $factory = Factory::getInstance(); $factory->config->plugins->revert(); } }