Example #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;
 }
Example #2
0
 public function testLogFailure_AddsExceptionContext()
 {
     $message = "Testing";
     $exception = new \Exception("Expected Exception");
     $this->mockLogger->log(Argument::type('string'), Argument::type('string'), Argument::withEntry('exception', $exception))->shouldBeCalledTimes(1);
     $this->testedBuildLogger->logFailure($message, $exception);
 }
Example #3
0
 /**
  * Add a failure-coloured message to the log.
  * @param string $message
  * @param \Exception $exception The exception that caused the error.
  */
 public function logFailure($message, \Exception $exception = null)
 {
     $this->buildLogger->logFailure($message, $exception);
 }