@@ -8,166 +8,166 @@ |
||
| 8 | 8 | class ArchangelTest extends PHPUnit_Framework_TestCase |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - public function testIsInstanceOfArchangel() |
|
| 12 | - { |
|
| 13 | - $archangel = new Archangel(); |
|
| 14 | - |
|
| 15 | - $this->assertInstanceOf('Jacobemerick\Archangel\Archangel', $archangel); |
|
| 16 | - } |
|
| 11 | + public function testIsInstanceOfArchangel() |
|
| 12 | + { |
|
| 13 | + $archangel = new Archangel(); |
|
| 14 | + |
|
| 15 | + $this->assertInstanceOf('Jacobemerick\Archangel\Archangel', $archangel); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testIsLoggerAwareInterface() |
|
| 19 | - { |
|
| 20 | - $archangel = new Archangel(); |
|
| 21 | - |
|
| 22 | - $this->assertInstanceOf('Psr\Log\LoggerAwareInterface', $archangel); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function testConstructSetsDefaultMailer() |
|
| 26 | - { |
|
| 27 | - $archangel = new Archangel(); |
|
| 28 | - $mailer = sprintf('PHP/%s', phpversion()); |
|
| 29 | - $headers = array('X-Mailer' => $mailer); |
|
| 30 | - |
|
| 31 | - $this->assertAttributeEquals($headers, 'headers', $archangel); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function testConstructOverridesMailer() |
|
| 35 | - { |
|
| 36 | - $archangel = new Archangel('AwesomeMailer'); |
|
| 37 | - $headers = array('X-Mailer' => 'AwesomeMailer'); |
|
| 38 | - |
|
| 39 | - $this->assertAttributeEquals($headers, 'headers', $archangel); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function testConstructSetsNullLogger() |
|
| 43 | - { |
|
| 44 | - $archangel = new Archangel(); |
|
| 45 | - |
|
| 46 | - $this->assertAttributeInstanceOf('Psr\Log\NullLogger', 'logger', $archangel); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function testSetLogger() |
|
| 50 | - { |
|
| 51 | - $logger = $this->getMock('Psr\Log\LoggerInterface'); |
|
| 52 | - $archangel = new Archangel(); |
|
| 53 | - $archangel->setLogger($logger); |
|
| 54 | - |
|
| 55 | - $this->assertAttributeSame($logger, 'logger', $archangel); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function testAddTo() |
|
| 59 | - { |
|
| 60 | - $archangel = new Archangel(); |
|
| 61 | - $archangel->addTo('[email protected]'); |
|
| 62 | - |
|
| 63 | - $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function testAddToMultiple() |
|
| 67 | - { |
|
| 68 | - $archangel = new Archangel(); |
|
| 69 | - $archangel->addTo('[email protected]'); |
|
| 70 | - $archangel->addTo('[email protected]'); |
|
| 71 | - |
|
| 72 | - $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 73 | - $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - public function testAddToWithTitle() |
|
| 77 | - { |
|
| 78 | - $archangel = new Archangel(); |
|
| 79 | - $archangel->addTo('[email protected]', 'Mr. Test Alot'); |
|
| 80 | - |
|
| 81 | - $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'toAddresses', $archangel); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function testAddCc() |
|
| 85 | - { |
|
| 86 | - $archangel = new Archangel(); |
|
| 87 | - $archangel->addCc('[email protected]'); |
|
| 88 | - |
|
| 89 | - $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - public function testAddCcMultiple() |
|
| 93 | - { |
|
| 94 | - $archangel = new Archangel(); |
|
| 95 | - $archangel->addCc('[email protected]'); |
|
| 96 | - $archangel->addCc('[email protected]'); |
|
| 97 | - |
|
| 98 | - $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 99 | - $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - public function testAddCcWithTitle() |
|
| 103 | - { |
|
| 104 | - $archangel = new Archangel(); |
|
| 105 | - $archangel->addCc('[email protected]', 'Mr. Test Alot'); |
|
| 106 | - |
|
| 107 | - $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'ccAddresses', $archangel); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - public function testAddBcc() |
|
| 111 | - { |
|
| 112 | - $archangel = new Archangel(); |
|
| 113 | - $archangel->addBcc('[email protected]'); |
|
| 114 | - |
|
| 115 | - $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function testAddBccMultiple() |
|
| 119 | - { |
|
| 120 | - $archangel = new Archangel(); |
|
| 121 | - $archangel->addBcc('[email protected]'); |
|
| 122 | - $archangel->addBcc('[email protected]'); |
|
| 123 | - |
|
| 124 | - $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 125 | - $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function testAddBccWithTitle() |
|
| 129 | - { |
|
| 130 | - $archangel = new Archangel(); |
|
| 131 | - $archangel->addBcc('[email protected]', 'Mr. Test Alot'); |
|
| 132 | - |
|
| 133 | - $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'bccAddresses', $archangel); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - public function testSetFrom() |
|
| 137 | - { |
|
| 138 | - $archangel = new Archangel(); |
|
| 139 | - $archangel->setFrom('[email protected]'); |
|
| 140 | - $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 141 | - |
|
| 142 | - $this->assertArraySubset(array('From' => '[email protected]'), $setHeaders); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - public function testSetFromMultiple() |
|
| 146 | - { |
|
| 147 | - $archangel = new Archangel(); |
|
| 148 | - $archangel->setFrom('[email protected]'); |
|
| 149 | - $archangel->setFrom('[email protected]'); |
|
| 150 | - $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 151 | - |
|
| 152 | - $this->assertArraySubset(array('From' => '[email protected]'), $setHeaders); |
|
| 153 | - $this->assertNotContains('[email protected]', $setHeaders); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - public function testSetFromWithTitle() |
|
| 157 | - { |
|
| 158 | - $archangel = new Archangel(); |
|
| 159 | - $archangel->setFrom('[email protected]', 'Mr. Test Alot'); |
|
| 160 | - $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 161 | - |
|
| 162 | - $this->assertArraySubset(array('From' => '"Mr. Test Alot" <[email protected]>'), $setHeaders); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - protected function getProtectedProperty($archangel, $property) |
|
| 166 | - { |
|
| 167 | - $reflectedArchangel = new ReflectionClass($archangel); |
|
| 168 | - $reflectedProperty = $reflectedArchangel->getProperty($property); |
|
| 169 | - $reflectedProperty->setAccessible(true); |
|
| 170 | - |
|
| 171 | - return $reflectedProperty->getValue($archangel); |
|
| 172 | - } |
|
| 18 | + public function testIsLoggerAwareInterface() |
|
| 19 | + { |
|
| 20 | + $archangel = new Archangel(); |
|
| 21 | + |
|
| 22 | + $this->assertInstanceOf('Psr\Log\LoggerAwareInterface', $archangel); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function testConstructSetsDefaultMailer() |
|
| 26 | + { |
|
| 27 | + $archangel = new Archangel(); |
|
| 28 | + $mailer = sprintf('PHP/%s', phpversion()); |
|
| 29 | + $headers = array('X-Mailer' => $mailer); |
|
| 30 | + |
|
| 31 | + $this->assertAttributeEquals($headers, 'headers', $archangel); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function testConstructOverridesMailer() |
|
| 35 | + { |
|
| 36 | + $archangel = new Archangel('AwesomeMailer'); |
|
| 37 | + $headers = array('X-Mailer' => 'AwesomeMailer'); |
|
| 38 | + |
|
| 39 | + $this->assertAttributeEquals($headers, 'headers', $archangel); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function testConstructSetsNullLogger() |
|
| 43 | + { |
|
| 44 | + $archangel = new Archangel(); |
|
| 45 | + |
|
| 46 | + $this->assertAttributeInstanceOf('Psr\Log\NullLogger', 'logger', $archangel); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function testSetLogger() |
|
| 50 | + { |
|
| 51 | + $logger = $this->getMock('Psr\Log\LoggerInterface'); |
|
| 52 | + $archangel = new Archangel(); |
|
| 53 | + $archangel->setLogger($logger); |
|
| 54 | + |
|
| 55 | + $this->assertAttributeSame($logger, 'logger', $archangel); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function testAddTo() |
|
| 59 | + { |
|
| 60 | + $archangel = new Archangel(); |
|
| 61 | + $archangel->addTo('[email protected]'); |
|
| 62 | + |
|
| 63 | + $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function testAddToMultiple() |
|
| 67 | + { |
|
| 68 | + $archangel = new Archangel(); |
|
| 69 | + $archangel->addTo('[email protected]'); |
|
| 70 | + $archangel->addTo('[email protected]'); |
|
| 71 | + |
|
| 72 | + $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 73 | + $this->assertAttributeContains('[email protected]', 'toAddresses', $archangel); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + public function testAddToWithTitle() |
|
| 77 | + { |
|
| 78 | + $archangel = new Archangel(); |
|
| 79 | + $archangel->addTo('[email protected]', 'Mr. Test Alot'); |
|
| 80 | + |
|
| 81 | + $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'toAddresses', $archangel); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function testAddCc() |
|
| 85 | + { |
|
| 86 | + $archangel = new Archangel(); |
|
| 87 | + $archangel->addCc('[email protected]'); |
|
| 88 | + |
|
| 89 | + $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + public function testAddCcMultiple() |
|
| 93 | + { |
|
| 94 | + $archangel = new Archangel(); |
|
| 95 | + $archangel->addCc('[email protected]'); |
|
| 96 | + $archangel->addCc('[email protected]'); |
|
| 97 | + |
|
| 98 | + $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 99 | + $this->assertAttributeContains('[email protected]', 'ccAddresses', $archangel); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + public function testAddCcWithTitle() |
|
| 103 | + { |
|
| 104 | + $archangel = new Archangel(); |
|
| 105 | + $archangel->addCc('[email protected]', 'Mr. Test Alot'); |
|
| 106 | + |
|
| 107 | + $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'ccAddresses', $archangel); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + public function testAddBcc() |
|
| 111 | + { |
|
| 112 | + $archangel = new Archangel(); |
|
| 113 | + $archangel->addBcc('[email protected]'); |
|
| 114 | + |
|
| 115 | + $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function testAddBccMultiple() |
|
| 119 | + { |
|
| 120 | + $archangel = new Archangel(); |
|
| 121 | + $archangel->addBcc('[email protected]'); |
|
| 122 | + $archangel->addBcc('[email protected]'); |
|
| 123 | + |
|
| 124 | + $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 125 | + $this->assertAttributeContains('[email protected]', 'bccAddresses', $archangel); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function testAddBccWithTitle() |
|
| 129 | + { |
|
| 130 | + $archangel = new Archangel(); |
|
| 131 | + $archangel->addBcc('[email protected]', 'Mr. Test Alot'); |
|
| 132 | + |
|
| 133 | + $this->assertAttributeContains('"Mr. Test Alot" <[email protected]>', 'bccAddresses', $archangel); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + public function testSetFrom() |
|
| 137 | + { |
|
| 138 | + $archangel = new Archangel(); |
|
| 139 | + $archangel->setFrom('[email protected]'); |
|
| 140 | + $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 141 | + |
|
| 142 | + $this->assertArraySubset(array('From' => '[email protected]'), $setHeaders); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + public function testSetFromMultiple() |
|
| 146 | + { |
|
| 147 | + $archangel = new Archangel(); |
|
| 148 | + $archangel->setFrom('[email protected]'); |
|
| 149 | + $archangel->setFrom('[email protected]'); |
|
| 150 | + $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 151 | + |
|
| 152 | + $this->assertArraySubset(array('From' => '[email protected]'), $setHeaders); |
|
| 153 | + $this->assertNotContains('[email protected]', $setHeaders); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + public function testSetFromWithTitle() |
|
| 157 | + { |
|
| 158 | + $archangel = new Archangel(); |
|
| 159 | + $archangel->setFrom('[email protected]', 'Mr. Test Alot'); |
|
| 160 | + $setHeaders = $this->getProtectedProperty($archangel, 'headers'); |
|
| 161 | + |
|
| 162 | + $this->assertArraySubset(array('From' => '"Mr. Test Alot" <[email protected]>'), $setHeaders); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + protected function getProtectedProperty($archangel, $property) |
|
| 166 | + { |
|
| 167 | + $reflectedArchangel = new ReflectionClass($archangel); |
|
| 168 | + $reflectedProperty = $reflectedArchangel->getProperty($property); |
|
| 169 | + $reflectedProperty->setAccessible(true); |
|
| 170 | + |
|
| 171 | + return $reflectedProperty->getValue($archangel); |
|
| 172 | + } |
|
| 173 | 173 | } |