public function testSetInvalidHeaders() { $request = Request::create('/'); $mode = new NginxMode([['directory' => __DIR__ . '/Unknown/Dir', 'mount-point' => '/download']]); $mode->setHeaders($request); $this->assertArrayNotHasKey('x-sendfile-type', $request->headers->all()); $this->assertArrayNotHasKey('x-accel-mapping', $request->headers->all()); }
public function testDeliverFileWithFilenameAndDispositionAndXSendFileButFileNotInXAccelMapping() { BinaryFileResponse::trustXSendfileTypeHeader(); $this->factory = new ServeFileResponseFactory(new \unicode()); $mode = new NginxMode([['directory' => __DIR__ . '/../../../../files/', 'mount-point' => '/protected/']]); $request = Request::create('/'); $mode->setHeaders($request); $file = __DIR__ . '/../../../../classes/PhraseanetTestCase.php'; $response = $this->factory->deliverFile($file, 'PhraseanetTestCase.php', 'attachment'); $response->prepare($request); $this->assertInstanceOf("Symfony\\Component\\HttpFoundation\\Response", $response); $this->assertEquals('attachment; filename="PhraseanetTestCase.php"', $response->headers->get('content-disposition')); $this->assertEquals(realpath($file), $response->headers->get('x-accel-redirect')); }