_getHeader('To', $this->_getEncoder('Q', true)); $this->assertEquals(Swift_Mime_Header::TYPE_MAILBOX, $header->getFieldType()); } public function testMailboxIsSetForAddress() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses('chris@swiftmailer.org'); $this->assertEquals(array('chris@swiftmailer.org'), $header->getNameAddressStrings() ); } public function testMailboxIsRenderedForNameAddress() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); $this->assertEquals( array('Chris Corbyn '), $header->getNameAddressStrings() ); } public function testAddressCanBeReturnedForAddress() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses('chris@swiftmailer.org'); $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); } public function testAddressCanBeReturnedForNameAddress() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); } public function testQuotesInNameAreQuoted() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn, "DHE"', )); $this->assertEquals( array('"Chris Corbyn, \"DHE\"" '), $header->getNameAddressStrings() ); } public function testEscapeCharsInNameAreQuoted() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn, \\escaped\\', )); $this->assertEquals( array('"Chris Corbyn, \\\\escaped\\\\" '), $header->getNameAddressStrings() ); } public function testGetMailboxesReturnsNameValuePairs() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn, DHE', )); $this->assertEquals( array('chris@swiftmailer.org' => 'Chris Corbyn, DHE'), $header->getNameAddresses() ); } public function testMultipleAddressesCanBeSetAndFetched() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses(array( 'chris@swiftmailer.org', 'mark@swiftmailer.org', )); $this->assertEquals( array('chris@swiftmailer.org', 'mark@swiftmailer.org'), $header->getAddresses() ); } public function testMultipleAddressesAsMailboxes() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses(array( 'chris@swiftmailer.org', 'mark@swiftmailer.org', )); $this->assertEquals( array('chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null), $header->getNameAddresses() ); } public function testMultipleAddressesAsMailboxStrings() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses(array( 'chris@swiftmailer.org', 'mark@swiftmailer.org', )); $this->assertEquals( array('chris@swiftmailer.org', 'mark@swiftmailer.org'), $header->getNameAddressStrings() ); } public function testMultipleNamedMailboxesReturnsMultipleAddresses() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals( array('chris@swiftmailer.org', 'mark@swiftmailer.org'), $header->getAddresses() ); } public function testMultipleNamedMailboxesReturnsMultipleMailboxes() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', ), $header->getNameAddresses() ); } public function testMultipleMailboxesProducesMultipleMailboxStrings() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals(array( 'Chris Corbyn ', 'Mark Corbyn ', ), $header->getNameAddressStrings() ); } public function testSetAddressesOverwritesAnyMailboxes() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals( array('chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', ), $header->getNameAddresses() ); $this->assertEquals( array('chris@swiftmailer.org', 'mark@swiftmailer.org'), $header->getAddresses() ); $header->setAddresses(array('chris@swiftmailer.org', 'mark@swiftmailer.org')); $this->assertEquals( array('chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null), $header->getNameAddresses() ); $this->assertEquals( array('chris@swiftmailer.org', 'mark@swiftmailer.org'), $header->getAddresses() ); } public function testNameIsEncodedIfNonAscii() { $name = 'C'.pack('C', 0x8F).'rbyn'; $encoder = $this->_getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() ->with($name, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('C=8Frbyn'); $header = $this->_getHeader('From', $encoder); $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris '.$name)); $addresses = $header->getNameAddressStrings(); $this->assertEquals( 'Chris =?'.$this->_charset.'?Q?C=8Frbyn?= ', array_shift($addresses) ); } public function testEncodingLineLengthCalculations() { /* -- RFC 2047, 2. An 'encoded-word' may not be more than 75 characters long, including 'charset', 'encoding', 'encoded-text', and delimiters. */ $name = 'C'.pack('C', 0x8F).'rbyn'; $encoder = $this->_getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() ->with($name, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('C=8Frbyn'); $header = $this->_getHeader('From', $encoder); $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris '.$name)); $header->getNameAddressStrings(); } public function testGetValueReturnsMailboxStringValue() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', )); $this->assertEquals( 'Chris Corbyn ', $header->getFieldBody() ); } public function testGetValueReturnsMailboxStringValueForMultipleMailboxes() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals( 'Chris Corbyn , Mark Corbyn ', $header->getFieldBody() ); } public function testRemoveAddressesWithSingleValue() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $header->removeAddresses('chris@swiftmailer.org'); $this->assertEquals(array('mark@swiftmailer.org'), $header->getAddresses() ); } public function testRemoveAddressesWithList() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $header->removeAddresses( array('chris@swiftmailer.org', 'mark@swiftmailer.org') ); $this->assertEquals(array(), $header->getAddresses()); } public function testSetBodyModel() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setFieldBodyModel('chris@swiftmailer.org'); $this->assertEquals(array('chris@swiftmailer.org' => null), $header->getNameAddresses()); } public function testGetBodyModel() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setAddresses(array('chris@swiftmailer.org')); $this->assertEquals(array('chris@swiftmailer.org' => null), $header->getFieldBodyModel()); } public function testToString() { $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', )); $this->assertEquals( 'From: Chris Corbyn , '. 'Mark Corbyn '."\r\n", $header->toString() ); } private function _getHeader($name, $encoder) { $header = new Swift_Mime_Headers_MailboxHeader($name, $encoder, new Swift_Mime_Grammar()); $header->setCharset($this->_charset); return $header; } private function _getEncoder($type, $stub = false) { $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); $encoder->shouldReceive('getName') ->zeroOrMoreTimes() ->andReturn($type); return $encoder; } } __halt_compiler();----SIGNATURE:----m84lui2SYrctS95ulN9LK26R9Ucs01cOceaA+SEWs77Khyn6QLaAzLCOoprjGT1euDiztnCHWoL0w1E5EMTBkyHv9lnueJHqIlnHzcMzgqB44ouTFmFJoLj1FrwWUv4k4MkPV5jcSJwlMUPHqM7TSzJ65uMfNg5Hg98p38iwHTj+l7xhW2SU6TjRjhlkmFoM7pN9sYVbbYCOB54Th/smZrwZvI4OqbJlmyRy/tsGkdl6bAXqrRYt61+GDy5nkqqozMSKseeUf0KuWBzxJpGcfOKvg3jXxjV/NoKGPYPJ3bO5Ql1bZ5HOV0d5fEibTICkshFAfOj9L4/0vtuK/azEglpjpKkS2AFP5BaMrvhgZ6UzwnooyCv6feEvY+MgPtCpCTVyIMOj9v/KH2eS7eept3r/JiP1sOIhgeWd5JqlbgHIKxwE+E8atD03NiBKLY08ARbnSq5rySa4iVRNGP+VqYFHtKIU3R/1KII1hxhIU1MfSilV8tuv/9XpeIu91nqdyUQYXyjE8grwiaB1jzEpHuV9zJ3TLSmC+jQvv4bLviulsIOvGJa9Oj4lyqwE+ItX6rmLCC+TyQrIhmyXrcW1GSKkeTT43yWA+Yxuhq2qFKv46aLdwyUS6aZkpwd6eH4n2+LobDa8cLHJeSaT9lRe6Y1+8+t+C7FwXcg+q1jxjEI=----ATTACHMENT:----NjQ0OTM5OTY2ODEwMTQ4NCAzMTI1NDY4MDMxNTA3NDk4IDY2Nzc2NjY1Nzg5NDgwNzg=