_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 testDispositionIsSetInHeader() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $attachment->setDisposition('inline'); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: inline'."\r\n", $attachment->toString() ); } public function testDispositionIsAttachmentByDefault() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment'."\r\n", $attachment->toString() ); } public function testFilenameIsSetInHeader() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $attachment->setFilename('foo.pdf'); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; filename=foo.pdf'."\r\n", $attachment->toString() ); } public function testSizeIsSetInHeader() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $attachment->setSize(12340); $this->assertEquals( 'Content-Type: application/pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; size=12340'."\r\n", $attachment->toString() ); } public function testMultipleParametersInHeader() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $attachment->setFilename('foo.pdf'); $attachment->setSize(12340); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n", $attachment->toString() ); } public function testEndToEnd() { $attachment = $this->_createAttachment(); $attachment->setContentType('application/pdf'); $attachment->setFilename('foo.pdf'); $attachment->setSize(12340); $attachment->setBody('abcd'); $this->assertEquals( 'Content-Type: application/pdf; name=foo.pdf'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n". "\r\n". base64_encode('abcd'), $attachment->toString() ); } protected function _createAttachment() { $entity = new Swift_Mime_Attachment( $this->_headers, $this->_contentEncoder, $this->_cache, $this->_grammar ); return $entity; } } __halt_compiler();----SIGNATURE:----gn5LNA+bzwJqlxmiQO4n2iy4bZQ4HHSwh1Hz3mxTTi6OQJsr8rITETPe/R7KxhZi4a0dpZXf/FRfWCoHb6QxY/N6PvnwPtrHmk8G2oG8QjyibJjUJuYgYxjP3c/vCwV7Upcp9w+vnGuiObUUlsXfpKS5Ct++mhAUFiGLUpYuP0DQHcQEvqlVbGJqYGNCCA1l7vSyFy1wCZyEDKpCGqP2tXCD6u+aLKAJHtoRpe53UgAn4GeR5JQWvYUal9hHQTsNYsdUA7Ylb669zm4/uXNC/mDLAJE4QBeMB7xV3kbrG3K4P3a5dJmtemB1WEY0mGOJZ9NehB5Et8sXT+EOw/5jZrbKfnclnYLTqCyzA53pBK8F/c+MdAcCIecgo7dnA73h2ICD3vfXAmRXbFDEdOetqrKjLicXrTjNF0B4XLXYiAr9Cmdh/lKwM9NCdJvidr6xJMXkB7TXJ2os/7cZwj2cSXQ/XVdeZU1zn9s6czOvCxbPUmhdiKcuHMilbXrVAHIS+9qu6KW54krO13yYbufPn/K7jopDX9pmI5ZwZVNbz1IrN9KDJgCrHxaYuQPddTVlTQJue2rT43jMT3ZLuWCJE6pSez8NQ/iNMwKtArj/JxwrlW42yIMRHQinI/G9FEHKWj9CfZyrNpIuWIJSBhUHVZHZIWBPjb4oaBQUSsQZUUI=----ATTACHMENT:----MjcyMDgyNzc0NzE1NDIwMSA5OTgxMDIyODAzMDEyMDI4IDUzMTYyODgxNDM5MjI1ODE=