public function testAddCodeRollbackAndCompletion() { $collection = new Collection(); $rollback1 = new CountingTask(); $rollback2 = new CountingTask(); $completion1 = new CountingTask(); $completion2 = new CountingTask(); $collection->progressMessage("start collection tasks")->rollback($rollback1)->completion($completion1)->rollbackCode(function () use($rollback1) { $rollback1->run(); })->completionCode(function () use($completion1) { $completion1->run(); })->addCode(function () { return 42; })->progressMessage("not reached")->rollback($rollback2)->completion($completion2)->addCode(function () { return 13; }); $collection->setLogger($this->guy->logger()); $result = $collection->run(); // Execution stops on the first error. // Confirm that status code is converted to a Result object. verify($result->getExitCode())->equals(42); verify($rollback1->getCount())->equals(2); verify($rollback2->getCount())->equals(0); verify($completion1->getCount())->equals(2); verify($completion2->getCount())->equals(0); $this->guy->seeInOutput('start collection tasks'); $this->guy->doNotSeeInOutput('not reached'); }
public function testParallelExec() { $task = new \Robo\Task\Base\ParallelExec(); $task->setLogger($this->guy->logger()); $result = $task->process('ls 1')->process('ls 2')->process('ls 3')->run(); $this->process->verifyInvokedMultipleTimes('start', 3); verify($result->getExitCode())->equals(0); $this->guy->seeInOutput("3 processes finished"); }