function ImageTest::testThemeImageWithSrc
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::testThemeImageWithSrc()
- 8.9.x 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 84
Class
- ImageTest
- Tests built-in image theme functions.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testThemeImageWithSrc() : void {
$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($this->fileUrlGenerator
->generateString($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.