Esempio n. 1
0
 public function testBasics()
 {
     $task = new ResultDummyTask();
     $result = new Result($task, 1, 'The foo barred', ['time' => 0]);
     $this->guy->seeInOutput('The foo barred');
     $this->guy->seeInOutput('Error');
     $this->guy->seeInOutput('[ResultDummyTask]');
     $this->assertSame($task, $result->getTask());
     $this->assertEquals(1, $result->getExitCode());
     $this->assertEquals('The foo barred', $result->getMessage());
     $this->assertEquals(['time' => 0], $result->getData());
     $taskClone = $result->cloneTask();
     $this->assertNotSame($task, $taskClone);
     $this->assertInstanceOf('Robo\\Task\\Shared\\TaskInterface', $taskClone);
 }
Esempio n. 2
0
 /**
  * Run every task in a list, but only up to the first failure.
  * Return the failing result, or success if all tasks run.
  *
  * @param string $name
  * @param TaskInterface[] $taskList
  * @param \Robo\Result $result
  *
  * @return \Robo\Result
  *
  * @throws \Robo\Exception\TaskExitException
  */
 private function runTaskList($name, array $taskList, Result $result)
 {
     try {
         foreach ($taskList as $taskName => $task) {
             $taskResult = $this->runSubtask($task);
             $this->advanceProgressIndicator();
             // If the current task returns an error code, then stop
             // execution and signal a rollback.
             if (!$taskResult->wasSuccessful()) {
                 return $taskResult;
             }
             // We accumulate our results into a field so that tasks that
             // have a reference to the collection may examine and modify
             // the incremental results, if they wish.
             $key = Result::isUnnamed($taskName) ? $name : $taskName;
             $result->accumulate($key, $taskResult);
         }
     } catch (TaskExitException $exitException) {
         $this->fail();
         throw $exitException;
     } catch (\Exception $e) {
         // Tasks typically should not throw, but if one does, we will
         // convert it into an error and roll back.
         return Result::fromException($task, $e, $result->getData());
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Merge another result into this result.  Data already
  * existing in this result takes precedence over the
  * data in the Result being merged.
  */
 public function merge(Result $result)
 {
     $this->data += $result->getData();
     return $this;
 }