示例#1
0
 /**
  * Executes a given plugin, with options and returns the result.
  */
 public function executePlugin($plugin, $options)
 {
     // Any plugin name without a namespace separator is a PHPCI built in plugin
     // if not we assume it's a fully name-spaced class name that implements the plugin interface.
     // If not the factory will throw an exception.
     if (strpos($plugin, '\\') === false) {
         $class = str_replace('_', ' ', $plugin);
         $class = ucwords($class);
         $class = 'PHPCI\\Plugin\\' . str_replace(' ', '', $class);
     } else {
         $class = $plugin;
     }
     if (!class_exists($class)) {
         $this->logger->logFailure(Lang::get('plugin_missing', $plugin));
         return false;
     }
     $rtn = true;
     // Try running it:
     try {
         $obj = $this->pluginFactory->buildPlugin($class, $options);
         if (!$obj->execute()) {
             $rtn = false;
         }
     } catch (\Exception $ex) {
         $this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
         $rtn = false;
     }
     return $rtn;
 }
示例#2
0
 public function testAddConfigFromFile_RegistersResources()
 {
     $this->testedFactory->addConfigFromFile(realpath(__DIR__ . "/ExamplePluginConfig.php"));
     $pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg');
     $plugin = $this->testedFactory->buildPlugin($pluginClass);
     // The Example config file defines an array as the resource.
     $this->assertEquals(array("bar" => "Hello"), $plugin->RequiredArgument);
 }
示例#3
0
 public function testAddConfigFromFile_RegistersResources()
 {
     $this->testedFactory->addConfigFromFile(realpath(__DIR__ . "/ExamplePluginConfig.php"));
     $namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
     $pluginName = $namespace . 'ExamplePluginWithSingleRequiredArg';
     $plugin = $this->testedFactory->buildPlugin($pluginName);
     // The Example config file defines an array as the resource.
     $this->assertEquals(array("bar" => "Hello"), $plugin->RequiredArgument);
 }