Ejemplo n.º 1
0
 /**
  * @dataProvider getSampleXAccelMappings
  */
 public function testXAccelMapping($realpath, $mapping, $virtual)
 {
     $request = Request::create('/');
     $request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect');
     $request->headers->set('X-Accel-Mapping', $mapping);
     $file = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\File')->disableOriginalConstructor()->getMock();
     $file->expects($this->any())->method('getRealPath')->will($this->returnValue($realpath));
     $file->expects($this->any())->method('isReadable')->will($this->returnValue(true));
     BinaryFileResponse::trustXSendFileTypeHeader();
     $response = new BinaryFileResponse('README.md');
     $reflection = new \ReflectionObject($response);
     $property = $reflection->getProperty('file');
     $property->setAccessible(true);
     $property->setValue($response, $file);
     $response->prepare($request);
     $this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect'));
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider getSampleXAccelMappings
  */
 public function testXAccelMapping($realpath, $mapping, $virtual)
 {
     $request = Request::create('/');
     $request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect');
     $request->headers->set('X-Accel-Mapping', $mapping);
     $file = new FakeFile($realpath, __DIR__ . '/File/Fixtures/test');
     BinaryFileResponse::trustXSendFileTypeHeader();
     $response = new BinaryFileResponse($file);
     $reflection = new \ReflectionObject($response);
     $property = $reflection->getProperty('file');
     $property->setAccessible(true);
     $property->setValue($response, $file);
     $response->prepare($request);
     $this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect'));
 }