Skip to content

Commit 758716c

Browse files
Add tests
1 parent b63c978 commit 758716c

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sudo: false
99

1010
env:
1111
global:
12-
- DEFAULT=0
12+
- DEFAULT=1
1313

1414
matrix:
1515
fast_finish: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Elastic Email Plugin for CakePHP 3
4+
* Copyright (c) PNG Labz (https://www.pnglabz.com)
5+
*
6+
* Licensed under The MIT License
7+
* For full copyright and license information, please see the LICENSE.md
8+
* Redistributions of files must retain the above copyright notice.
9+
*
10+
* @copyright Copyright (c) PNG Labz (https://www.pnglabz.com)
11+
* @license https://opensource.org/licenses/mit-license.php MIT License
12+
* @link https://github.com/pnglabz/cakephp-elastic-email
13+
* @since 1.0.0
14+
*/
15+
namespace ElasticEmail\Test\TestCase\Mailer\Transport;
16+
17+
use Cake\Mailer\Email;
18+
use Cake\TestSuite\TestCase;
19+
20+
class ElasticEmailTransportTest extends TestCase
21+
{
22+
public function setUp()
23+
{
24+
parent::setUp();
25+
}
26+
27+
public function testMissingApiKey()
28+
{
29+
$this->expectException('ElasticEmail\Mailer\Exception\MissingElasticEmailApiKeyException');
30+
31+
Email::setConfigTransport(
32+
'elasticemail',
33+
[
34+
'className' => 'ElasticEmail.ElasticEmail',
35+
'apiKey' => ''
36+
]
37+
);
38+
39+
$email = new Email();
40+
$email->setProfile(['transport' => 'elasticemail']);
41+
$email->setFrom(['from@example.com' => 'CakePHP Elastic Email'])
42+
->setTo('to@example.com')
43+
->setEmailFormat('both')
44+
->setSubject('{title} - Email from CakePHP Elastic Email plugin')
45+
->send('Hello {firstname} {lastname}, <br> This is an email from CakePHP Elastic Email plugin.');
46+
}
47+
}

0 commit comments

Comments
 (0)