You are here

public function BlazyEntityTest::testGetEntityView in Blazy 8.2

Tests the entity view builder.

@covers ::getEntityView @dataProvider providerTestGetEntityView

Parameters

string $entity: The tested entity.

string $fallback: The fallback text.

string $message: The message text.

bool $expected: The expected output.

File

tests/src/Kernel/BlazyEntityTest.php, line 45

Class

BlazyEntityTest
Tests the Blazy entity methods.

Namespace

Drupal\Tests\blazy\Kernel

Code

public function testGetEntityView($entity, $fallback, $message, $expected) {
  if ($entity == 'node') {
    $entity = empty($this->entity) ? $this
      ->setUpContentWithItems($this->bundle) : $this->entity;
  }
  elseif ($entity == 'responsive_image') {
    $entity = $this->blazyManager
      ->entityLoad('blazy_responsive_test', 'responsive_image_style');
  }
  elseif ($entity == 'image') {
    $entity = $this->testItem;
  }
  $result = $this->blazyEntity
    ->getEntityView($entity, [], $fallback);
  $this
    ->assertSame($expected, !empty($result), $message);
}