You are here

public function DownloadTest::testMediaDownloadHeaders in Media Download 1.0.x

Same name and namespace in other branches
  1. 1.2.x tests/src/Functional/DownloadTest.php \Drupal\Tests\media_download\Functional\DownloadTest::testMediaDownloadHeaders()
  2. 1.1.x tests/src/Functional/DownloadTest.php \Drupal\Tests\media_download\Functional\DownloadTest::testMediaDownloadHeaders()

Tests that the response is cacheable and contains the correct disposition.

@covers \Drupal\media_download\CacheableBinaryFileResponse @covers \Drupal\media_download\DownloadController::getFile

File

tests/src/Functional/DownloadTest.php, line 183

Class

DownloadTest
Tests that the download functionality works as expected.

Namespace

Drupal\Tests\media_download\Functional

Code

public function testMediaDownloadHeaders() {
  $this
    ->drupalLogin($this->owner);

  // Ensure that a 404 is returned.
  $this
    ->drupalGet($this->media
    ->toUrl('canonical')
    ->toString());
  $this
    ->assertSession()
    ->responseHeaderNotEquals('Cache-Control', '');
  $this
    ->assertSession()
    ->responseHeaderContains('Content-Disposition', 'inline');
  $this
    ->assertSession()
    ->responseHeaderContains('Content-Disposition', 'filename=');
}