function ImageStylesPathAndUrlTest::testImageStyleUrlForMissingSourceImage

Same name in other branches
  1. 9 core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php \Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest::testImageStyleUrlForMissingSourceImage()
  2. 8.9.x core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php \Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest::testImageStyleUrlForMissingSourceImage()
  3. 11.x core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php \Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest::testImageStyleUrlForMissingSourceImage()

Tests that an invalid source image returns a 404.

File

core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php, line 142

Class

ImageStylesPathAndUrlTest
Tests the functions for generating paths and URLs for image styles.

Namespace

Drupal\Tests\image\Functional

Code

public function testImageStyleUrlForMissingSourceImage() : void {
    $non_existent_uri = 'public://foo.png';
    $generated_url = $this->style
        ->buildUrl($non_existent_uri);
    $this->drupalGet($generated_url);
    $this->assertSession()
        ->statusCodeEquals(404);
}

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