You are here

public function BlazyManagerTest::testPreprocessResponsiveImage in Blazy 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/BlazyManagerTest.php \Drupal\Tests\blazy\Kernel\BlazyManagerTest::testPreprocessResponsiveImage()

Tests responsive image integration.

@dataProvider providerResponsiveImage

Parameters

string $responsive_image_style_id: The responsive_image_style_id.

bool $old: Whether to use Drupal core 8.x-2, or later 8.x-3.

bool $expected: The expected output_image_tag.

File

tests/src/Kernel/BlazyManagerTest.php, line 289

Class

BlazyManagerTest
Tests the Blazy manager methods.

Namespace

Drupal\Tests\blazy\Kernel

Code

public function testPreprocessResponsiveImage($responsive_image_style_id, $old, $expected) {
  $variables = [
    'item' => $this->testItem,
    'uri' => $this->uri,
    'responsive_image_style_id' => $responsive_image_style_id,
  ];
  template_preprocess_responsive_image($variables);
  if ($old) {
    $variables['img_element']['#srcset'][0]['uri'] = $this->uri;
  }
  else {
    $variables['img_element']['#uri'] = $this->uri;
  }
  Blazy::preprocessResponsiveImage($variables);
  $this
    ->assertEquals($expected, $variables['output_image_tag']);
}