function ImageTest::testThemeImageWithSrc
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::testThemeImageWithSrc()
- 10 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::testThemeImageWithSrc()
- 11.x core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::testThemeImageWithSrc()
Tests that an image with the src attribute is output correctly.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ ImageTest.php, line 69
Class
- ImageTest
- Tests built-in image theme functions.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testThemeImageWithSrc() {
$image = [
'#theme' => 'image',
'#uri' => reset($this->testImages),
'#width' => rand(0, 1000) . 'px',
'#height' => rand(0, 500) . 'px',
'#alt' => $this->randomMachineName(),
'#title' => $this->randomMachineName(),
];
$this->render($image);
// Make sure the src attribute has the correct value.
$this->assertRaw(file_url_transform_relative(file_create_url($image['#uri'])), 'Correct output for an image with the src attribute.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.