From 2b93fe0c9417a630edbb84176b9566275c5342ea Mon Sep 17 00:00:00 2001 From: meadsteve Date: Tue, 25 Feb 2014 22:36:20 +0000 Subject: [PATCH 1/2] add getProjectTitle convenience method to the Build class. --- PHPCI/Helper/BuildInterpolator.php | 2 +- PHPCI/Model/Build.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/PHPCI/Helper/BuildInterpolator.php b/PHPCI/Helper/BuildInterpolator.php index 4732607c..d4609793 100644 --- a/PHPCI/Helper/BuildInterpolator.php +++ b/PHPCI/Helper/BuildInterpolator.php @@ -27,7 +27,7 @@ class BuildInterpolator $this->interpolation_vars['%COMMIT%'] = $build->getCommitId(); $this->interpolation_vars['%PROJECT%'] = $build->getProjectId(); $this->interpolation_vars['%BUILD%'] = $build->getId(); - $this->interpolation_vars['%PROJECT_TITLE%'] = $build->getProject()->getTitle(); + $this->interpolation_vars['%PROJECT_TITLE%'] = $build->getProjectTitle(); $this->interpolation_vars['%BUILD_PATH%'] = $buildPath; $this->interpolation_vars['%BUILD_URI%'] = $phpCiUrl . "build/view/" . $build->getId(); $this->interpolation_vars['%PHPCI_COMMIT%'] = $this->interpolation_vars['%COMMIT%']; diff --git a/PHPCI/Model/Build.php b/PHPCI/Model/Build.php index f17fcc74..ff0a0b23 100644 --- a/PHPCI/Model/Build.php +++ b/PHPCI/Model/Build.php @@ -36,6 +36,15 @@ class Build extends BuildBase return '#'; } + /** + * @return string + */ + public function getProjectTitle() + { + $project = $this->getProject(); + return $project ? $project->getTitle() : ""; + } + /** * Get link to branch from another source (i.e. Github) */ From 06625513d278b5aa6dd8bde1e007aa308810eb48 Mon Sep 17 00:00:00 2001 From: meadsteve Date: Tue, 25 Feb 2014 22:39:37 +0000 Subject: [PATCH 2/2] update email tests now that cc can be specified. --- PHPCI/Plugin/Email.php | 7 ++++--- Tests/PHPCI/Plugin/EmailTest.php | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PHPCI/Plugin/Email.php b/PHPCI/Plugin/Email.php index 05dbe4c0..5d29de65 100644 --- a/PHPCI/Plugin/Email.php +++ b/PHPCI/Plugin/Email.php @@ -106,9 +106,10 @@ class Email implements \PHPCI\Plugin } /** - * @param array|string $toAddresses Array or single address to send to - * @param string $subject Email subject - * @param string $body Email body + * @param string[]|string $toAddresses Array or single address to send to + * @param string[] $ccList + * @param string $subject Email subject + * @param string $body Email body * @return array Array of failed addresses */ public function sendEmail($toAddresses, $ccList, $subject, $body) diff --git a/Tests/PHPCI/Plugin/EmailTest.php b/Tests/PHPCI/Plugin/EmailTest.php index 84618001..87225772 100644 --- a/Tests/PHPCI/Plugin/EmailTest.php +++ b/Tests/PHPCI/Plugin/EmailTest.php @@ -162,7 +162,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase { $this->mockMailer->expects($this->once()) ->method('send'); - $this->testedEmailPlugin->sendEmail("test@email.com", "hello", "body"); + $this->testedEmailPlugin->sendEmail("test@email.com", array(), "hello", "body"); } /** @@ -177,7 +177,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase $this->mockMailer->expects($this->once()) ->method('send') ->with($this->isInstanceOf('\Swift_Message'), $this->anything()); - $this->testedEmailPlugin->sendEmail($toAddress, $subject, $body); + $this->testedEmailPlugin->sendEmail($toAddress, array(), $subject, $body); } /** @@ -197,7 +197,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase $actualMail = null; $this->catchMailPassedToSend($actualMail); - $this->testedEmailPlugin->sendEmail($toAddress, $subject, $body); + $this->testedEmailPlugin->sendEmail($toAddress, array(), $subject, $body); $this->assertSystemMail( $toAddress,