You are here

public function ImageStylesPathAndUrlTest::testImageStylePath in Drupal 8

Same name and namespace in other branches
  1. 9 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.');
}