/** * Just because we use Swift_File doesn't neccesarily mean we want to use it's filename. * Make sure you can still set it. */ public function testFileNameCanBeOverriddenEvenWhenUsingFileStream() { $attachment = new Swift_Message_Attachment(new Swift_File(TestConfiguration::FILES_PATH . "/manchester.jpeg"), "foo.bar"); $this->assertEqual("foo.bar", $attachment->getFileName()); $structure = $attachment->build()->readFull(); $this->assertPattern("~Content-Type: application/octet-stream;\\s* name=(\"?)(foo\\.bar)\\1\r\nContent-Transfer-Encoding: base64\r\n" . "Content-Description: \\2\r\nContent-Disposition: attachment;\\s* filename=(\"?)\\2\\3\r\n\r\n.*~s", $structure); $attachment = new Swift_Message_Attachment(new Swift_File(TestConfiguration::FILES_PATH . "/manchester.jpeg")); $attachment->setFileName("zip.button"); $this->assertEqual("zip.button", $attachment->getFileName()); $structure = $attachment->build()->readFull(); $this->assertPattern("~Content-Type: application/octet-stream;\\s* name=(\"?)(zip\\.button)\\1\r\nContent-Transfer-Encoding: base64\r\n" . "Content-Description: \\2\r\nContent-Disposition: attachment;\\s* filename=(\"?)\\2\\3\r\n\r\n.*~s", $structure); $attachment = new Swift_Message_Attachment(new Swift_File(TestConfiguration::FILES_PATH . "/manchester.jpeg"), "foo.bar"); $attachment->setFileName("test.file"); $this->assertEqual("test.file", $attachment->getFileName()); $structure = $attachment->build()->readFull(); $this->assertPattern("~Content-Type: application/octet-stream;\\s* name=(\"?)(test\\.file)\\1\r\nContent-Transfer-Encoding: base64\r\n" . "Content-Description: \\2\r\nContent-Disposition: attachment;\\s* filename=(\"?)\\2\\3\r\n\r\n.*~s", $structure); }