You are here

protected function LinkEmbedFormatterTest::renderTestEntity in URL Embed 8

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.

1 call to LinkEmbedFormatterTest::renderTestEntity()
LinkEmbedFormatterTest::testLinkEmbedFormatter in tests/src/Functional/LinkEmbedFormatterTest.php
Tests the 'url_embed' formatter.

File

tests/src/Functional/LinkEmbedFormatterTest.php, line 95

Class

LinkEmbedFormatterTest
Tests url_embed link field formatter.

Namespace

Drupal\Tests\url_embed\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);
  $output = (string) $output;
  $this
    ->verbose($output);
  return $output;
}