You are here

protected function RenderWebTest::assertRenderedElement in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Common/RenderWebTest.php \Drupal\system\Tests\Common\RenderWebTest::assertRenderedElement()

Tests that elements are rendered properly.

1 call to RenderWebTest::assertRenderedElement()
RenderWebTest::testDrupalRenderFormElements in core/modules/system/src/Tests/Common/RenderWebTest.php
Tests rendering form elements without passing through \Drupal::formBuilder()->doBuildForm().

File

core/modules/system/src/Tests/Common/RenderWebTest.php, line 169
Contains \Drupal\system\Tests\Common\RenderWebTest.

Class

RenderWebTest
Performs integration tests on drupal_render().

Namespace

Drupal\system\Tests\Common

Code

protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
  $original_element = $element;
  $this
    ->setRawContent(drupal_render_root($element));
  $this
    ->verbose('<hr />' . $this
    ->getRawContent());

  // @see \Drupal\simpletest\WebTestBase::xpath()
  $xpath = $this
    ->buildXPathQuery($xpath, $xpath_args);
  $element += array(
    '#value' => NULL,
  );
  $this
    ->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', array(
    '@type' => var_export($element['#type'], TRUE),
  )));
}