1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jacobemerick\Archangel; |
4
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
6
|
|
|
|
7
|
|
|
class ArchangelTest extends PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function testIsInstanceOfArchangel() |
11
|
|
|
{ |
12
|
|
|
$archangel = new Archangel(); |
13
|
|
|
|
14
|
|
|
$this->assertInstanceOf('Jacobemerick\Archangel\Archangel', $archangel); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function testIsLoggerAwareInterface() |
18
|
|
|
{ |
19
|
|
|
$archangel = new Archangel(); |
20
|
|
|
|
21
|
|
|
$this->assertInstanceOf('Psr\Log\LoggerAwareInterface', $archangel); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testConstructSetsDefaultMailer() |
25
|
|
|
{ |
26
|
|
|
$archangel = new Archangel(); |
27
|
|
|
$mailer = sprintf('PHP/%s', phpversion()); |
28
|
|
|
$headers = array('X-Mailer' => $mailer); |
29
|
|
|
|
30
|
|
|
$this->assertAttributeEquals($headers, 'headers', $archangel); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testConstructOverridesMailer() |
34
|
|
|
{ |
35
|
|
|
$archangel = new Archangel('AwesomeMailer'); |
36
|
|
|
$headers = array('X-Mailer' => 'AwesomeMailer'); |
37
|
|
|
|
38
|
|
|
$this->assertAttributeEquals($headers, 'headers', $archangel); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testConstructSetsNullLogger() |
42
|
|
|
{ |
43
|
|
|
$archangel = new Archangel(); |
44
|
|
|
|
45
|
|
|
$this->assertAttributeInstanceOf('Psr\Log\NullLogger', 'logger', $archangel); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testSetLogger() |
49
|
|
|
{ |
50
|
|
|
$logger = $this->getMock('Psr\Log\LoggerInterface'); |
51
|
|
|
$archangel = new Archangel(); |
52
|
|
|
$archangel->setLogger($logger); |
53
|
|
|
|
54
|
|
|
$this->assertAttributeSame($logger, 'logger', $archangel); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testAddTo() |
58
|
|
|
{ |
59
|
|
|
$archangel = new Archangel(); |
60
|
|
|
$archangel->addTo('[email protected]'); |
61
|
|
|
|
62
|
|
|
$this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testAddToMultiple() |
66
|
|
|
{ |
67
|
|
|
$archangel = new Archangel(); |
68
|
|
|
$archangel->addTo('[email protected]'); |
69
|
|
|
$archangel->addTo('[email protected]'); |
70
|
|
|
|
71
|
|
|
$this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
72
|
|
|
$this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testAddToWithTitle() |
76
|
|
|
{ |
77
|
|
|
$archangel = new Archangel(); |
78
|
|
|
$archangel->addTo('[email protected]', 'Mr. Test Alot'); |
79
|
|
|
|
80
|
|
|
$this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'toAddresses', $archangel); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|