public function BlazyManagerTest::testPreprocessBlazy in Blazy 8.2
Tests building Blazy attributes.
@covers \Drupal\blazy\Blazy::preprocessBlazy @covers \Drupal\blazy\Blazy::urlAndDimensions @covers \Drupal\blazy\BlazyDefault::entitySettings @dataProvider providerPreprocessBlazy
Parameters
array $settings: The settings being tested.
bool $use_uri: Whether to provide image URI, 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 125
Class
- BlazyManagerTest
- Tests the Blazy manager methods.
Namespace
Drupal\Tests\blazy\KernelCode
public function testPreprocessBlazy(array $settings, $use_uri, $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'] = $use_uri ? $this->uri : '';
if (!empty($settings['embed_url'])) {
$settings = array_merge(BlazyDefault::entitySettings(), $settings);
}
$variables['element']['#item'] = $this->testItem;
$variables['element']['#settings'] = $settings;
Blazy::preprocessBlazy($variables);
$image = $expected == TRUE ? !empty($variables['image']) : empty($variables['image']);
$iframe = $iframe == TRUE ? !empty($variables['iframe']) : empty($variables['iframe']);
$this
->assertTrue($image);
$this
->assertTrue($iframe);
}