You are here

public function BinaryFileResponseTest::testXAccelMapping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php \Symfony\Component\HttpFoundation\Tests\BinaryFileResponseTest::testXAccelMapping()

@dataProvider getSampleXAccelMappings

File

vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php, line 174

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 = new FakeFile($realpath, __DIR__ . '/File/Fixtures/test');
  BinaryFileResponse::trustXSendfileTypeHeader();
  $response = new BinaryFileResponse($file, 200, array(
    'Content-Type' => 'application/octet-stream',
  ));
  $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'));
}