Example #1
0
 /**
  * @covers PHPUnit::execute
  */
 public function testExecute_TestIsSuccessful()
 {
     $build = new Build();
     $build->setStatus(Build::STATUS_NEW);
     $this->assertFalse($build->isSuccessful());
     $build->setStatus(Build::STATUS_RUNNING);
     $this->assertFalse($build->isSuccessful());
     $build->setStatus(Build::STATUS_FAILED);
     $this->assertFalse($build->isSuccessful());
     $build->setStatus(Build::STATUS_SUCCESS);
     $this->assertTrue($build->isSuccessful());
 }
 /**
  * Runs the shell command.
  */
 public function execute()
 {
     $success = false;
     $successfulBuild = $this->build->isSuccessful();
     if ($successfulBuild) {
         $success = $this->callDeploymentUrl($this->deployUrl, $this->requestMethod);
     }
     return $success;
 }
Example #3
0
 /**
  * Send a notification mail.
  */
 public function execute()
 {
     $addresses = $this->getEmailAddresses();
     // Without some email addresses in the yml file then we
     // can't do anything.
     if (count($addresses) == 0) {
         return false;
     }
     $buildStatus = $this->build->isSuccessful() ? "Passing Build" : "Failing Build";
     $projectName = $this->build->getProject()->getTitle();
     $mailTemplate = $this->build->isSuccessful() ? 'Email/success' : 'Email/failed';
     $view = new View($mailTemplate);
     $view->build = $this->build;
     $view->project = $this->build->getProject();
     $body = $view->render();
     $sendFailures = $this->sendSeparateEmails($addresses, sprintf("PHPCI - %s - %s", $projectName, $buildStatus), $body);
     // This is a success if we've not failed to send anything.
     $this->phpci->log(sprintf("%d emails sent", count($addresses) - $sendFailures));
     $this->phpci->log(sprintf("%d emails failed to send", $sendFailures));
     return $sendFailures === 0;
 }
Example #4
0
 /**
  * Get the default mail template.
  *
  * @return View
  */
 protected function getDefaultMailTemplate()
 {
     $template = $this->build->isSuccessful() ? 'short' : 'long';
     return new View('Email/' . $template);
 }