getHeaders(); $this->assertEquals('attachment; filename=file', $headers['Content-Disposition']); $this->assertEquals('content', $headers['Content-Type']); } #[\PHPUnit\Framework\Attributes\DataProvider('filenameEncodingProvider')] public function testFilenameEncoding(string $input, string $expectedDisposition): void { $response = new ChildDownloadResponse($input, 'content'); $headers = $response->getHeaders(); $this->assertEquals($expectedDisposition, $headers['Content-Disposition']); } public static function filenameEncodingProvider(): array { return [ ['TestName.txt', 'attachment; filename=TestName.txt'], ['A "Quoted" Filename.txt', 'attachment; filename="A \"Quoted\" Filename.txt"'], ['A "Quoted" Filename.txt', 'attachment; filename="A \"Quoted\" Filename.txt"'], ['A "Quoted" Filename With A Backslash \\.txt', 'attachment; filename="A \"Quoted\" Filename With A Backslash -.txt"'], ['A "Very" Weird Filename \ / & <> " >\'""""\.text', 'attachment; filename="A \"Very\" Weird Filename - - & <> \" >\'\"\"\"\"-.text"'], ['\\\\\\\\\\\\', 'attachment; filename=------'], ]; } public function testSpecialCharactersInFilename(): void { $filename = 'document "draft" with; special&chars.pdf'; $response = new ChildDownloadResponse($filename, 'application/pdf'); $headers = $response->getHeaders(); $this->assertEquals( 'attachment; filename="document \"draft\" with; special&chars.pdf"', $headers['Content-Disposition'] ); } }