function RenderedEntityTest::testRenderNullEntity

Same name in other branches
  1. 11.x core/modules/views/tests/src/Unit/Plugin/views/field/RenderedEntityTest.php \Drupal\Tests\views\Unit\Plugin\views\field\RenderedEntityTest::testRenderNullEntity()

Tests the render method when getEntity returns NULL.

@covers ::render

File

core/modules/views/tests/src/Unit/Plugin/views/field/RenderedEntityTest.php, line 39

Class

RenderedEntityTest
@coversDefaultClass \Drupal\views\Plugin\views\field\RenderedEntity @group Views

Namespace

Drupal\Tests\views\Unit\Plugin\views\field

Code

public function testRenderNullEntity() : void {
    $row = new ResultRow();
    $field = new RenderedEntity([
        'entity_type' => 'foo',
        'entity field' => 'bar',
    ], '', [], $this->createMock(EntityTypeManagerInterface::class), $this->createMock(LanguageManagerInterface::class), $this->createMock(EntityRepositoryInterface::class), $this->createMock(EntityDisplayRepositoryInterface::class));
    $view = $this->createMock(ViewExecutable::class);
    $display = $this->createMock(DisplayPluginBase::class);
    $field->init($view, $display);
    $this->assertEmpty($field->render($row));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.