You are here

public function DownloadTest::testMediaDownloadFileMissingOnDisk 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::testMediaDownloadFileMissingOnDisk()
  2. 1.1.x tests/src/Functional/DownloadTest.php \Drupal\Tests\media_download\Functional\DownloadTest::testMediaDownloadFileMissingOnDisk()

Tests that a 404 is returned when the target file is missing on disk.

@covers \Drupal\media_download\DownloadController::getFile

File

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

Class

DownloadTest
Tests that the download functionality works as expected.

Namespace

Drupal\Tests\media_download\Functional

Code

public function testMediaDownloadFileMissingOnDisk() {
  $file = $this->media->field_media_document->entity;
  $this
    ->assertNotNull($file);
  unlink($file
    ->getFileUri());
  $this
    ->drupalLogin($this->owner);

  // Ensure that a 404 is returned.
  $this
    ->drupalGet($this->media
    ->toUrl('canonical')
    ->toString());
  $this
    ->assertSession()
    ->statusCodeEquals(404);
}