_cache = new Swift_KeyCache_ArrayKeyCache( new Swift_KeyCache_SimpleKeyCacheInputStream() ); $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); $this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') ); $paramEncoder = new Swift_Encoder_Rfc2231Encoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') ); $this->_grammar = new Swift_Mime_Grammar(); $this->_headers = new Swift_Mime_SimpleHeaderSet( new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) ); } public function testContentIdIsSetInHeader() { $file = $this->_createEmbeddedFile(); $file->setContentType('application/pdf'); $file->setId('foo@bar'); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: '."\r\n". 'Content-Disposition: inline'."\r\n", $file->toString() ); } public function testDispositionIsSetInHeader() { $file = $this->_createEmbeddedFile(); $id = $file->getId(); $file->setContentType('application/pdf'); $file->setDisposition('attachment'); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: attachment'."\r\n", $file->toString() ); } public function testFilenameIsSetInHeader() { $file = $this->_createEmbeddedFile(); $id = $file->getId(); $file->setContentType('application/pdf'); $file->setFilename('foo.pdf'); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; filename=foo.pdf'."\r\n", $file->toString() ); } public function testSizeIsSetInHeader() { $file = $this->_createEmbeddedFile(); $id = $file->getId(); $file->setContentType('application/pdf'); $file->setSize(12340); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; size=12340'."\r\n", $file->toString() ); } public function testMultipleParametersInHeader() { $file = $this->_createEmbeddedFile(); $id = $file->getId(); $file->setContentType('application/pdf'); $file->setFilename('foo.pdf'); $file->setSize(12340); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n", $file->toString() ); } public function testEndToEnd() { $file = $this->_createEmbeddedFile(); $id = $file->getId(); $file->setContentType('application/pdf'); $file->setFilename('foo.pdf'); $file->setSize(12340); $file->setBody('abcd'); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n". "\r\n". base64_encode('abcd'), $file->toString() ); } protected function _createEmbeddedFile() { $entity = new Swift_Mime_EmbeddedFile( $this->_headers, $this->_contentEncoder, $this->_cache, $this->_grammar ); return $entity; } } __halt_compiler();----SIGNATURE:----leEJk85rgpta+H5Nx+v/aHSjQqbl0WqDpFgykWG1BKz9jFL0Ch3PRnKkpNl+TDNQE6t5jJiIYVbTDRomlByOdDWbFOWoTijfEnkqp8awcJgc3j0732R2NYF+Q09konQmkw0Ue5gp+dCWeIA9ED+X6rARJQNlCF7VMrRwwC+2aAfqMNzA26vHLkhLou2M1yWJQ+QTsR2BleD0+mvoeLEygW5PDTQHdwSzMBQmFRWjZZ391WGtGhyBfqziAAv8BcN6P+zQr7QQ3lHD7w9PRDtzD8WvtsdhPd/8BxATt3FYkjvNevqsndAvOc3C5glIoz/vEyh/uihlZOv79/yJw3WonJOcPEIlJjFzxwfVRHnpXftMw65UtGCNUPFGwjdAQDN5MfMhgNCT8pw0Y0qUOLjxj0uIlegEHD6kIHPdveIWZS8Ig29SKCVLpqhz2QvKF56fq2mhWIbSOs+kKihX2Y9932wcKzpbbTViAYzHMAZT9O+rTQ/1jKZ/ZfnnYO+s/OhaWQHJ0NMo4izsT4CJYjb6sddZfUFbOacK58+nwSdlGBj6lxFLp0cg5o4gIgOGRKbsi8sq/Hqh7IQyT5ltzzHFXYlmHoULesVwCPb6XacFrQ5vgRDGVY/ExvLf0gbfANVu5/g8NE6x0rWQ1A1SVcPTTb3+IQox9sivl48wsCGG4tM=----ATTACHMENT:----NTY2MTQ3NTU5ODk5ODE5NyAzNzI3NDY3ODQzODcwMTQgMzI3MjY5NzkxNTQ4NjY0NA==