allow swiftmailer object to be passed in to Email Plugin.
This commit is contained in:
parent
a56df8ed87
commit
51f73458c8
|
@ -40,7 +40,11 @@ class Email implements \PHPCI\Plugin
|
|||
*/
|
||||
protected $mailer;
|
||||
|
||||
public function __construct(Builder $phpci, Build $build, array $options = array())
|
||||
public function __construct(Builder $phpci,
|
||||
Build $build,
|
||||
array $options = array(),
|
||||
\Swift_Mailer $mailer = null
|
||||
)
|
||||
{
|
||||
$phpCiSettings = $phpci->getSystemConfig('phpci');
|
||||
$this->phpci = $phpci;
|
||||
|
@ -48,7 +52,12 @@ class Email implements \PHPCI\Plugin
|
|||
$this->options = $options;
|
||||
$this->emailConfig = isset($phpCiSettings['email_settings']) ? $phpCiSettings['email_settings'] : array();
|
||||
|
||||
$this->loadSwiftMailerFromConfig();
|
||||
if ($mailer) {
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
else {
|
||||
$this->loadSwiftMailerFromConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
namespace PHPCI\Plugin\Tests;
|
||||
use PHPCI\Plugin\Email as EmailPlugin;
|
||||
|
||||
define('PHPCI_BIN_DIR', "FAKEPHPCIBIN");
|
||||
|
||||
/**
|
||||
* Unit test for the PHPUnit plugin.
|
||||
* @author meadsteve
|
||||
*/
|
||||
class EmailTest extends \PHPUnit_Framework_TestCase
|
||||
class EmailTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -43,7 +42,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->mockBuild = $this->getMock(
|
||||
'\PHPCI\Model\Build',
|
||||
array('getLog'),
|
||||
array('getLog', 'getStatus'),
|
||||
array(),
|
||||
"mockBuild",
|
||||
false
|
||||
|
@ -53,6 +52,10 @@ class EmailTest extends \PHPUnit_Framework_TestCase
|
|||
->method('getLog')
|
||||
->will($this->returnValue("Build Log"));
|
||||
|
||||
$this->mockBuild->expects($this->any())
|
||||
->method('getStatus')
|
||||
->will($this->returnValue(\PHPCI\Model\Build::STATUS_SUCCESS));
|
||||
|
||||
$this->mockCiBuilder = $this->getMock(
|
||||
'\PHPCI\Builder',
|
||||
array('getSystemConfig',
|
||||
|
@ -96,6 +99,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->testedEmailPlugin = new EmailPlugin(
|
||||
$this->mockCiBuilder,
|
||||
$this->mockBuild,
|
||||
$arrOptions,
|
||||
$this->mockMailer
|
||||
);
|
Loading…
Reference in a new issue