You are here

public function ExposedFormTest::testExposedFormRender in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/ExposedFormTest.php \Drupal\views\Tests\Plugin\ExposedFormTest::testExposedFormRender()

Tests the exposed form markup.

File

core/modules/views/src/Tests/Plugin/ExposedFormTest.php, line 133
Contains \Drupal\views\Tests\Plugin\ExposedFormTest.

Class

ExposedFormTest
Tests exposed forms functionality.

Namespace

Drupal\views\Tests\Plugin

Code

public function testExposedFormRender() {
  $view = Views::getView('test_exposed_form_buttons');
  $this
    ->executeView($view);
  $exposed_form = $view->display_handler
    ->getPlugin('exposed_form');
  $output = $exposed_form
    ->renderExposedForm();
  $this
    ->setRawContent(\Drupal::service('renderer')
    ->renderRoot($output));
  $this
    ->assertFieldByXpath('//form/@id', $this
    ->getExpectedExposedFormId($view), 'Expected form ID found.');
  $view
    ->setDisplay('page_1');
  $expected_action = $view->display_handler
    ->getUrlInfo()
    ->toString();
  $this
    ->assertFieldByXPath('//form/@action', $expected_action, 'The expected value for the action attribute was found.');

  // Make sure the description is shown.
  $result = $this
    ->xpath('//form//div[contains(@id, :id) and normalize-space(text())=:description]', array(
    ':id' => 'edit-type--description',
    ':description' => t('Exposed description'),
  ));
  $this
    ->assertEqual(count($result), 1, 'Filter description was found.');
}