function ImageStylesPathAndUrlTest::testImageStylePath

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

Tests \Drupal\image\ImageStyleInterface::buildUri().

File

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

Class

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

Namespace

Drupal\Tests\image\Functional

Code

public function testImageStylePath() {
    $scheme = 'public';
    $actual = $this->style
        ->buildUri("{$scheme}://foo/bar.gif");
    $expected = "{$scheme}://styles/" . $this->style
        ->id() . "/{$scheme}/foo/bar.gif";
    $this->assertEqual($actual, $expected, 'Got the path for a file URI.');
    $actual = $this->style
        ->buildUri('foo/bar.gif');
    $expected = "{$scheme}://styles/" . $this->style
        ->id() . "/{$scheme}/foo/bar.gif";
    $this->assertEqual($actual, $expected, 'Got the path for a relative file path.');
}

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