You are here

public function DownloadTest::testMediaDownloadNoFileReference in Media Download 1.2.x

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

Tests that a 404 is returned when the media entity has no associated file.

@covers \Drupal\media_download\DownloadController::getFile

File

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

Class

DownloadTest
Tests that the download functionality works as expected.

Namespace

Drupal\Tests\media_download\Functional

Code

public function testMediaDownloadNoFileReference() {
  $this->media->field_media_document->entity = NULL;
  $this->media
    ->save();
  $this
    ->drupalLogin($this->owner);

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