protected function RenderTest::assertRenderedElement

Tests that elements are rendered properly.

1 call to RenderTest::assertRenderedElement()
RenderTest::testDrupalRenderFormElements in drupal/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
Tests rendering form elements without passing through form_builder().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php, line 341
Definition of Drupal\system\Tests\Common\RenderTest.

Class

RenderTest
Tests drupal_render().

Namespace

Drupal\system\Tests\Common

Code

protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
  $original_element = $element;
  $this
    ->drupalSetContent(drupal_render($element));
  $this
    ->verbose('<pre>' . check_plain(var_export($original_element, TRUE)) . '</pre>' . '<pre>' . check_plain(var_export($element, TRUE)) . '</pre>' . '<hr />' . $this
    ->drupalGetContent());

  // @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),
  )));
}