public function BlazyFormatterTest::testBlazyMedia in Blazy 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/BlazyFormatterTest.php \Drupal\Tests\blazy\Kernel\BlazyFormatterTest::testBlazyMedia()
Tests the Blazy formatter faked Media integration.
@dataProvider providerTestBlazyMedia
Parameters
mixed|string|bool $input_url: Input URL, else empty.
bool $expected: The expected output.
File
- tests/
src/ Kernel/ BlazyFormatterTest.php, line 174
Class
- BlazyFormatterTest
- Tests the Blazy image formatter.
Namespace
Drupal\Tests\blazy\KernelCode
public function testBlazyMedia($input_url, $expected) {
$entity = $this->entity;
$settings = [
'input_url' => $input_url,
'source_field' => $this->testFieldName,
'view_mode' => 'default',
'bundle' => $this->bundle,
'thumbnail_style' => 'thumbnail',
'uri' => $this->uri,
];
$build = $this->display
->build($entity);
$render = BlazyMedia::build($entity, $settings);
if ($expected && $render) {
$this
->assertNotEmpty($render);
$field[0] = $render;
$wrap = BlazyMedia::wrap($field, $settings);
$this
->assertNotEmpty($wrap);
$render = $this->blazyManager
->getRenderer()
->renderRoot($build[$this->testFieldName]);
$this
->assertTrue(strpos($render, 'data-blazy') !== FALSE);
}
else {
$this
->assertFalse($render);
}
}