function BinaryFileResponseTest::testCalculatedContentType

Test the content type generated by Drupal is correct.

@dataProvider providerTestCalculatedContentType

File

core/tests/Drupal/KernelTests/Core/Http/BinaryFileResponseTest.php, line 27

Class

BinaryFileResponseTest
Tests the headers added by BinaryFileResponse.

Namespace

Drupal\KernelTests\Core\Http

Code

public function testCalculatedContentType($path, $content_type) : void {
    $query = [
        'relative_file_url' => $path,
    ];
    $request = Request::create('/binary_file_response_test/download', 'GET', $query);
    $response = \Drupal::service('http_kernel')->handle($request);
    $response->prepare($request);
    $this->assertSame($content_type, current(explode(';', $response->headers
        ->get('Content-Type'))));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.