diff --git a/tests/ArchangelTest.php b/tests/ArchangelTest.php index 4dc0e0e..043a235 100644 --- a/tests/ArchangelTest.php +++ b/tests/ArchangelTest.php @@ -281,6 +281,24 @@ public function testAddAttachmentWithTitle() ); } + public function testSend() + { + $archangel = new Archangel(); + $archangel->addTo('test@example.com'); + $archangel->setSubject('Test Subject'); + $archangel->setPlainMessage('Plain text message'); + $response = $archangel->send(); + + $expectedResponse = array( + 'to' => 'test@example.com', + 'subject' => 'Test Subject', + 'message' => 'Plain text message' . Archangel::LINE_BREAK, + 'headers' => 'X-Mailer: PHP/6.0.0' . Archangel::LINE_BREAK, + ); + + $this->assertEquals($expectedResponse, $response); + } + /** * @dataProvider dataCheckRequiredFields */ @@ -411,6 +429,28 @@ public function dataCheckRequiredFields() ); } + public function testBuildTo() + { + $archangel = new Archangel(); + $addressesProperty = $this->getProtectedProperty('toAddresses'); + $addressesProperty->setValue($archangel, array('test@example.com')); + $buildMethod = $this->getProtectedMethod('buildTo'); + $toAddresses = $buildMethod->invoke($archangel); + + $this->assertEquals('test@example.com', $toAddresses); + } + + public function testBuildToMultiple() + { + $archangel = new Archangel(); + $addressesProperty = $this->getProtectedProperty('toAddresses'); + $addressesProperty->setValue($archangel, array('testOne@example.com', 'testTwo@example.com')); + $buildMethod = $this->getProtectedMethod('buildTo'); + $toAddresses = $buildMethod->invoke($archangel); + + $this->assertEquals('testOne@example.com, testTwo@example.com', $toAddresses); + } + public function testGetBoundary() { $archangel = new Archangel(); diff --git a/tests/function-overrides.php b/tests/function-overrides.php index 5dfbb8e..ffce4af 100644 --- a/tests/function-overrides.php +++ b/tests/function-overrides.php @@ -2,6 +2,14 @@ namespace Jacobemerick\Archangel; +function mail($to, $subject, $message, $headers) { + return compact('to', 'subject', 'message', 'headers'); +} + +function phpversion() { + return '6.0.0'; +} + function uniqid() { return '1234567890123'; }