function RenderElementTypesTest::assertElements

Asserts that an array of elements is rendered properly.

Parameters

array $elements: The render element array to test.

string $expected_html: The expected markup.

string $message: Assertion message.

2 calls to RenderElementTypesTest::assertElements()
RenderElementTypesTest::testContainer in core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
Tests system #type 'container'.
RenderElementTypesTest::testHtmlTag in core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
Tests system #type 'html_tag'.

File

core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php, line 39

Class

RenderElementTypesTest
Tests the markup of core render element types passed to drupal_render().

Namespace

Drupal\KernelTests\Core\Render\Element

Code

protected function assertElements(array $elements, $expected_html, $message) {
  $actual_html = (string) \Drupal::service('renderer')->renderRoot($elements);
  $out = '<table><tr>';
  $out .= '<td valign="top"><pre>' . Html::escape($expected_html) . '</pre></td>';
  $out .= '<td valign="top"><pre>' . Html::escape($actual_html) . '</pre></td>';
  $out .= '</tr></table>';
  $this->verbose($out);
  $this->assertIdentical($actual_html, $expected_html, Html::escape($message));
}

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