| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Metaways Infosystems GmbH, 2013 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Aimeos (aimeos.org), 2014 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | namespace Aimeos\MW\Mail\Message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | require_once dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'MailMessage'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestHeaderSet.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class Typo3Test extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	private $object; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	private $mock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * Sets up the fixture, for example, opens a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 * This method is called before a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		$this->mock = $this->getMock( 'TYPO3\\CMS\\Core\\Mail\\MailMessage' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		$this->object = new \Aimeos\MW\Mail\Message\Typo3( $this->mock, 'UTF-8' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 * Tears down the fixture, for example, closes a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 * This method is called after a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	protected function tearDown() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function testAddFrom() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		$this->mock->expects( $this->once() )->method( 'addFrom' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$result = $this->object->addFrom( 'a@b', 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 	public function testAddTo() | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 		$this->mock->expects( $this->once() )->method( 'addTo' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  | 		$result = $this->object->addTo( 'a@b', 'test' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	public function testAddCc() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		$this->mock->expects( $this->once() )->method( 'addCc' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		$result = $this->object->addCc( 'a@b', 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	public function testAddBcc() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		$this->mock->expects( $this->once() )->method( 'addBcc' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		$result = $this->object->addBcc( 'a@b', 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	public function testAddReplyTo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		$this->mock->expects( $this->once() )->method( 'addReplyTo' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		$result = $this->object->addReplyTo( 'a@b', 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	public function testAddHeader() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		$headersMock = $this->getMock( 'Aimeos\MW\Mail\Message\TestHeaderSet' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		$this->mock->expects( $this->once() )->method( 'getHeaders' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			->will( $this->returnValue( $headersMock ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		$headersMock->expects( $this->once() )->method( 'addTextHeader' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			->with( $this->stringContains( 'test' ), $this->stringContains( 'value' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		$result = $this->object->addHeader( 'test', 'value' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	public function testSetSender() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		$this->mock->expects( $this->once() )->method( 'setSender' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			->with( $this->stringContains( 'a@b' ), $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		$result = $this->object->setSender( 'a@b', 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	public function testSetSubject() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		$this->mock->expects( $this->once() )->method( 'setSubject' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 			->with( $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		$result = $this->object->setSubject( 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	public function testSetBody() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		$this->mock->expects( $this->once() )->method( 'setBody' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			->with( $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		$result = $this->object->setBody( 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	public function testSetBodyHtml() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		$this->mock->expects( $this->once() )->method( 'addPart' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 			->with( $this->stringContains( 'test' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		$result = $this->object->setBodyHtml( 'test' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 		$this->assertSame( $this->object, $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	public function testAddAttachment() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		$this->markTestIncomplete( 'Swift_Attachment::newInstance() is not testable' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	public function testEmbedAttachment() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		$this->markTestIncomplete( 'Swift_EmbeddedFile::newInstance() is not testable' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	public function testGetObject() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		$this->assertInstanceOf( 'TYPO3\\CMS\\Core\\Mail\\MailMessage', $this->object->getObject() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 167 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 168 |  |  |  |