public function BinaryFileResponseTest::testXAccelMapping

@dataProvider getSampleXAccelMappings

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php, line 114

Class

BinaryFileResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

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'));
}