function PermissionsTest::testPreRenderNullEntity

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

Tests the preRender method when getEntity returns NULL.

@covers ::preRender

File

core/modules/user/tests/src/Unit/Plugin/views/field/PermissionsTest.php, line 43

Class

PermissionsTest
@coversDefaultClass \Drupal\user\Plugin\views\field\Permissions @group user

Namespace

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

Code

public function testPreRenderNullEntity() : void {
    $values = [
        new ResultRow(),
    ];
    $field = new Permissions([
        'entity_type' => 'foo',
        'entity field' => 'bar',
    ], '', [], $this->createMock(ModuleHandlerInterface::class), $this->createMock(EntityTypeManagerInterface::class));
    $view = $this->createMock(ViewExecutable::class);
    $display = $this->createMock(DisplayPluginBase::class);
    $field->init($view, $display);
    $field->preRender($values);
    $this->assertEmpty($field->items);
}

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