public function BlazyManagerUnitTest::testPreRenderImage in Blazy 8
Tests for \Drupal\blazy\BlazyManager::preRenderImage().
@covers ::getImage @covers ::preRenderImage @dataProvider providerTestPreRenderImage
File
- tests/
src/ Unit/ BlazyManagerUnitTest.php, line 134
Class
- BlazyManagerUnitTest
- @coversDefaultClass \Drupal\blazy\BlazyManager
Namespace
Drupal\Tests\blazy\UnitCode
public function testPreRenderImage($item, $uri, $content, $expected_image, $expected_render) {
$build = [];
$build['item'] = $item ? $this->testItem : [];
$build['content'] = $content;
$build['settings'] = BlazyDefault::itemSettings();
$build['settings']['uri'] = $uri;
if ($item) {
$build['item']->_attributes['data-blazy-test'] = TRUE;
}
$image = $this->blazyManager
->getImage($build);
$build_image['#build']['settings'] = array_merge($this
->getCacheMetaData(), $build['settings']);
$build_image['#build']['item'] = $build['item'];
$pre_render = $this->blazyManager
->preRenderImage($build_image);
$check_image = !$expected_image ? empty($image) : !empty($image);
$this
->assertTrue($check_image);
$check_pre_render = !$expected_render ? TRUE : !empty($pre_render);
$this
->assertTrue($check_pre_render);
}