You are here

public function BlazyManagerTest::testGetEntityView in Blazy 8

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/BlazyManagerTest.php, line 127

Class

BlazyManagerTest
Tests the Blazy manager methods.

Namespace

Drupal\Tests\blazy\Kernel

Code

public function testGetEntityView($entity, $fallback, $message, $expected) {
  if ($entity == 'entity') {
    $entity_test = EntityTest::create([
      'name' => $this
        ->randomMachineName(),
    ]);
    $entity_test
      ->save();
    $entity = $entity_test;
  }
  elseif ($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->blazyManager
    ->getEntityView($entity, [], $fallback);
  $this
    ->assertSame($expected, !empty($result), $message);
}