public function BlazyManagerTest::testBuildAttributes in Blazy 8
Tests building Blazy attributes.
@covers \Drupal\blazy\Blazy::buildAttributes @covers \Drupal\blazy\Blazy::buildBreakpointAttributes @covers \Drupal\blazy\Blazy::buildUrl @covers \Drupal\blazy\Dejavu\BlazyDefault::entitySettings @dataProvider providerBuildAttributes
Parameters
array $settings: The settings being tested.
bool $uri: Whether to provide image URI, or not.
object $item: Whether to provide image item, or not.
bool $iframe: Whether to expect an iframe, or not.
mixed|bool|int $expected: The expected output.
File
- tests/
src/ Kernel/ BlazyManagerTest.php, line 206
Class
- BlazyManagerTest
- Tests the Blazy manager methods.
Namespace
Drupal\Tests\blazy\KernelCode
public function testBuildAttributes(array $settings, $uri, $item, $iframe, $expected) {
$variables = [
'attributes' => [],
];
$settings = array_merge($this
->getFormatterSettings(), $settings);
$settings += BlazyDefault::itemSettings();
$settings['blazy'] = TRUE;
$settings['lazy'] = 'blazy';
$settings['image_style'] = 'blazy_crop';
$settings['thumbnail_style'] = 'thumbnail';
$settings['uri'] = $uri ? $this->uri : '';
if (!empty($settings['embed_url'])) {
$settings = array_merge(BlazyDefault::entitySettings(), $settings);
}
$variables['element']['#item'] = $item ? $this->testItem : NULL;
$variables['element']['#settings'] = $settings;
Blazy::buildAttributes($variables);
$image = $expected == TRUE ? !empty($variables['image']) : empty($variables['image']);
$iframe = $iframe == TRUE ? !empty($variables['iframe_attributes']) : empty($variables['iframe_attributes']);
$this
->assertTrue($image);
$this
->assertTrue($iframe);
}