Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
narendravaghela committed May 22, 2016
1 parent 7130201 commit 3e32633
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/TestCase/Mailer/Transport/MailgunTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function setUp()
$this->validConfig = [
'apiKey' => 'My-Super-Awesome-API-Key',
'domain' => 'test.mailgun.org',
'apiVersion' => 'v3',
'ssl' => false,
'isTest' => true
];
Expand All @@ -44,14 +45,39 @@ public function setUp()
}

/**
* Test configuration
* Test missing api key exception
*
* @return void
*/
public function testInvalidConfig()
public function testMissingApiKey()
{
$this->setExpectedException('MailgunEmail\Mailer\Exception\MissingCredentialsException');
$this->MailgunTransport->config($this->invalidConfig);
$this->MailgunTransport->config([
'apiKey' => 'My-Super-Awesome-API-Key',
'domain' => ''
]);

$email = new Email();
$email->transport($this->MailgunTransport);
$email->from(['sender@test.mailgun.org' => 'Mailgun Test'])
->to('test@test.mailgun.org')
->subject('This is test subject')
->emailFormat('text')
->send('Testing Maingun');
}

/**
* Test missing domain exception
*
* @return void
*/
public function testMissingDomain()
{
$this->setExpectedException('MailgunEmail\Mailer\Exception\MissingCredentialsException');
$this->MailgunTransport->config([
'apiKey' => '',
'domain' => ''
]);

$email = new Email();
$email->transport($this->MailgunTransport);
Expand Down

0 comments on commit 3e32633

Please sign in to comment.