Esempio n. 1
0
    /**
     * Perform the work.
     *
     * @throws BuildException if there is an error.
     */
    public function main()
    {
        $errorMessages = '';
        for ($i = 0; $i <= $this->retryCount; $i++) {
            try {
                $this->nestedTask->perform();
                break;
            } catch (Exception $e) {
                $errorMessages .= $e->getMessage();
                if ($i >= $this->retryCount) {
                    $taskName = $this->nestedTask->getTaskName();
                    $exceptionMessage = <<<EXCEPTION_MESSAGE
Task [{$taskName}] failed after [{$this->retryCount}] attempts; giving up
Error messages:
{$errorMessages}
EXCEPTION_MESSAGE;
                    throw new BuildException($exceptionMessage, $this->getLocation());
                }
                if ($this->retryDelay > 0) {
                    $msg = sprintf('Attempt [%s]: error occurred; retrying after %s s...', $i, $this->retryDelay);
                } else {
                    $msg = sprintf('Attempt [%s]: error occurred; retrying...', $i);
                }
                $this->log($msg, Project::MSG_INFO);
                $errorMessages .= PHP_EOL;
                if ($this->retryDelay > 0) {
                    sleep($this->retryDelay);
                }
            }
        }
    }
Esempio n. 2
0
 /**
  *  Get the name of the task to use in logging messages.
  *
  * @return string The task's name
  */
 public function getTaskName()
 {
     return $this->realThing === null ? parent::getTaskName() : $this->realThing->getTaskName();
 }
 /**
  *  Get the name of the task to use in logging messages.
  *
  * @return string The task's name
  */
 public function getTaskName()
 {
     return $this->realThing === null || !$this->realThing instanceof Task ? parent::getTaskName() : $this->realThing->getTaskName();
 }
 function testUpdate()
 {
     //Arrange
     $task_name = "Wash the dog";
     $id = 1;
     $due_date = null;
     $test_task = new Task($task_name, $id, $due_date);
     $test_task->save();
     $new_task_name = "Clean the dog";
     //Act
     $test_task->update($new_task_name);
     //Assert
     $this->assertEquals("Clean the dog", $test_task->getTaskName());
 }