function FunctionsTest::testImage

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php \Drupal\Tests\system\Kernel\Theme\FunctionsTest::testImage()
  2. 10 core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php \Drupal\Tests\system\Kernel\Theme\FunctionsTest::testImage()
  3. 11.x core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php \Drupal\Tests\system\Kernel\Theme\FunctionsTest::testImage()

Tests theme_image().

File

core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php, line 523

Class

FunctionsTest
Tests for common theme functions.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testImage() {
    // Test that data URIs work with theme_image().
    $variables = [];
    $variables['uri'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
    $variables['alt'] = 'Data URI image of a red dot';
    $expected = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Data URI image of a red dot" />' . "\n";
    $this->assertThemeOutput('image', $variables, $expected);
}

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