BlazyEntityTest.php in Blazy 8.2
File
tests/src/Kernel/BlazyEntityTest.php
View source
<?php
namespace Drupal\Tests\blazy\Kernel;
class BlazyEntityTest extends BlazyKernelTestBase {
protected function setUp() {
parent::setUp();
$bundle = $this->bundle;
$settings['fields']['field_text_multiple'] = 'text';
$this
->setUpContentTypeTest($bundle, $settings);
$this
->setUpContentWithItems($bundle);
$this
->setUpRealImage();
}
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);
}
public function providerTestGetEntityView() {
return [
'Node' => [
'node',
'',
'Node has node_view() taking precedence over view builder.',
TRUE,
],
'Responsive image' => [
'responsive_image',
'This is some fallback text.',
'Responsive image has no view builder. Fallback to text.',
TRUE,
],
'Image' => [
'image',
'',
'Image is not an instance of EntityInterface, returns false.',
FALSE,
],
];
}
}