_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:----QZwI1Dpxzn/jwxxP/fBsGX8q6hb40hg25BMP5D1T4qDhgUGuDsBW+vKWCcfRlN9Pz5E/KHcKWRpqKOeY4RUSWGm35BPMop2WL7cxaUZocXxo7YjrKJ89G+OIsPHyKIS0viFSF0RNKZMkYDHjcccS8USB5gkF0FEYjtcJuJqIbft9ezUaDZuCC8sfOFQV/yd0GUmPiGSH9PV4jQPxEVgEWPN/ZBquoo9Sw70vOrV54Uu90s4ZzjGruDMwpaa7l6lNxvjU4pM+eCs04p/i834bhPj2GBE8SP9PYJf8thhRnxBOHE5X2ow5WLeDW+zFRjwQhhHkT0dS4hkwHNfqAZrKex22lehCpKv6udR9oFEbHJH0dLEKWfZzQzQEhYp2gaYolflaSXFIR9m8+hH7vbdYKRTbPaMNAfSYgB4EKHs01a5SgUPI1oNMQhRUKoeF0Q7m1mqfYCdttEAlglVkUN8epPonliq4nGcR4hR46cyAaU1dcmOP2r8BD4fHgwwqUaC+wrY3qTiRekLQ0SMSzOOqIYfCZAwCxxIESoQjzz1ViJGRDlch/Iid30ZhFyk0BqB18Zv7EwLwDhFRqdNw/iQW/pXocAAbqB/MgZyWl0z7Mn4UhnZHbjD+UDLUVpMYW/n8NYC4dVkt1pk8dbIG/L6rrTU+sOTpCMKgZrVmxNNnr+4=----ATTACHMENT:----MTE5NDg1MTYzMjA5MDgwOSAzNzE3NTQ5ODMyODIxMzgxIDUyODQ4OTkyNzY2MjAyOTY=