function EntityViewBuilderTest::testExternalEntity

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php \Drupal\KernelTests\Core\Entity\EntityViewBuilderTest::testExternalEntity()
  2. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php \Drupal\KernelTests\Core\Entity\EntityViewBuilderTest::testExternalEntity()

Tests an entity type with an external canonical rel.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php, line 350

Class

EntityViewBuilderTest
Tests the entity view builder.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testExternalEntity() {
    $this->installEntitySchema('entity_test_external');
    
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container
        ->get('renderer');
    $entity_test = $this->createTestEntity('entity_test_external');
    $entity_test->save();
    $view = $this->container
        ->get('entity_type.manager')
        ->getViewBuilder('entity_test_external')
        ->view($entity_test);
    $renderer->renderRoot($view);
    $this->assertArrayNotHasKey('#contextual_links', $view);
}

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