_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:----Uqyui1NmIBrw9o1so2Dc867YcQoh2E/iNHcojJx/tnj2yJfs9KyRPk3z1jddqiRSVhbbxn/We9pUj6ay71NMLIWeWnDP23ySDhKN/GSlLFM4+232pFobQDwLeOBny5sT4YNNPgyCyiCPeWdqF8YntGR/P2YewQ05FRwcIocpFOCcP6UZSlEkgx8fwduxRgQCHdMogJ5rLxBSA3SGzkHCaspOP20diP1y2ZiI6/khRGpyqaUX+atZVyeMwd61dURqnXKSIW4QqRlyfGz7t5z8mwpUWT3dQ7/vW0uZldsD2AlpeUYAFnn76W3owGNIgfyCmKoUWpLM3SjGpGwpfPOknjarJQGSY39DR3T7ueZd/GqZjNvZVuPJZBJ95SXIqBS605pBB8qpUUpt12XbXZudUQ1v4P4bvKsAduQHKr7qbK+o58yNIUeyiMBlO6AtUS58VvaoROAUIuolN7WYeQMHfWrIoMoYHJ71DqJ1b0ShwUzwjIrBcCCEYzhQY5x8xLNn+mGuye9Fr9Yfv9dv2fF5/vRjgyt8LmfQ57wXF/DSWM/0C5Qje84EN1XieL5YhePsGKg3hRkrDEXshrkNsbp1FThpDXss0Oo34HfVz/fN7RE2Luos9b2DuDNeKLhz0HiUbJninR5BJrmazjq+L6Cltam3DOrqeciK35fofp7ueEc=----ATTACHMENT:----OTk4OTUxMjAyNTI3ODY3OCA4NTgxMjMyMTE5MDUwNDkyIDI0MDUwMDQ4NDU5MTcwODc=