summaryrefslogtreecommitdiff
path: root/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php')
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php
new file mode 100644
index 0000000..a9f35e9
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php
@@ -0,0 +1,77 @@
+<?php
+
+class Swift_Mime_Headers_PathHeaderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testTypeIsPathHeader()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $this->assertEquals(Swift_Mime_Header::TYPE_PATH, $header->getFieldType());
+ }
+
+ public function testSingleAddressCanBeSetAndFetched()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('chris@swiftmailer.org');
+ $this->assertEquals('chris@swiftmailer.org', $header->getAddress());
+ }
+
+ public function testAddressMustComplyWithRfc2822()
+ {
+ try {
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('chr is@swiftmailer.org');
+ $this->fail('Addresses not valid according to RFC 2822 addr-spec grammar must be rejected.');
+ } catch (Exception $e) {
+ }
+ }
+
+ public function testValueIsAngleAddrWithValidAddress()
+ {
+ /* -- RFC 2822, 3.6.7.
+
+ return = "Return-Path:" path CRLF
+
+ path = ([CFWS] "<" ([CFWS] / addr-spec) ">" [CFWS]) /
+ obs-path
+ */
+
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('chris@swiftmailer.org');
+ $this->assertEquals('<chris@swiftmailer.org>', $header->getFieldBody());
+ }
+
+ public function testValueIsEmptyAngleBracketsIfEmptyAddressSet()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('');
+ $this->assertEquals('<>', $header->getFieldBody());
+ }
+
+ public function testSetBodyModel()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $header->setFieldBodyModel('foo@bar.tld');
+ $this->assertEquals('foo@bar.tld', $header->getAddress());
+ }
+
+ public function testGetBodyModel()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('foo@bar.tld');
+ $this->assertEquals('foo@bar.tld', $header->getFieldBodyModel());
+ }
+
+ public function testToString()
+ {
+ $header = $this->_getHeader('Return-Path');
+ $header->setAddress('chris@swiftmailer.org');
+ $this->assertEquals('Return-Path: <chris@swiftmailer.org>'."\r\n",
+ $header->toString()
+ );
+ }
+
+ private function _getHeader($name)
+ {
+ return new Swift_Mime_Headers_PathHeader($name, new Swift_Mime_Grammar());
+ }
+}