function LinkFieldTest::renderTestEntity

Same name in other branches
  1. 9 core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::renderTestEntity()
  2. 8.9.x core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::renderTestEntity()
  3. 11.x core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::renderTestEntity()

Renders a test_entity and returns the output.

Parameters

int $id: The test_entity ID to render.

string $view_mode: (optional) The view mode to use for rendering.

bool $reset: (optional) Whether to reset the entity_test storage cache. Defaults to TRUE to simplify testing.

Return value

string The rendered HTML output.

5 calls to LinkFieldTest::renderTestEntity()
LinkFieldTest::doTestLinkFormatter in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests the default 'link' formatter.
LinkFieldTest::doTestLinkSeparateFormatter in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests the 'link_separate' formatter.
LinkFieldTest::doTestLinkTitle in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests the link title settings of a link field.
LinkFieldTest::testLinkFormatterQueryParametersDuplication in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests the default 'link' formatter with complex query parameters.
LinkFieldTest::testNoLinkUri in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests <nolink> and <none> as link uri.

File

core/modules/link/tests/src/Functional/LinkFieldTest.php, line 1057

Class

LinkFieldTest
Tests link field widgets and formatters.

Namespace

Drupal\Tests\link\Functional

Code

protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
    if ($reset) {
        $this->container
            ->get('entity_type.manager')
            ->getStorage('entity_test')
            ->resetCache([
            $id,
        ]);
    }
    $entity = EntityTest::load($id);
    $display = \Drupal::service('entity_display.repository')->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
    $content = $display->build($entity);
    $output = \Drupal::service('renderer')->renderRoot($content);
    return (string) $output;
}

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