3 namespace Drupal\Tests\views\Kernel\Plugin;
5 use Drupal\Component\Utility\Html;
6 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
7 use Drupal\views\Views;
10 * Tests the exposed form markup.
13 * @see \Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest
15 class ExposedFormRenderTest extends ViewsKernelTestBase {
20 public static $testViews = ['test_exposed_form_buttons'];
25 public static $modules = ['node'];
30 protected function setUp($import_test_views = TRUE) {
32 $this->installEntitySchema('node');
36 * Tests the exposed form markup.
38 public function testExposedFormRender() {
39 $view = Views::getView('test_exposed_form_buttons');
40 $this->executeView($view);
41 $exposed_form = $view->display_handler->getPlugin('exposed_form');
42 $output = $exposed_form->renderExposedForm();
43 $this->setRawContent(\Drupal::service('renderer')->renderRoot($output));
45 $this->assertFieldByXpath('//form/@id', Html::cleanCssIdentifier('views-exposed-form-' . $view->storage->id() . '-' . $view->current_display), 'Expected form ID found.');
47 $view->setDisplay('page_1');
48 $expected_action = $view->display_handler->getUrlInfo()->toString();
49 $this->assertFieldByXPath('//form/@action', $expected_action, 'The expected value for the action attribute was found.');
50 // Make sure the description is shown.
51 $result = $this->xpath('//form//div[contains(@id, :id) and normalize-space(text())=:description]', [':id' => 'edit-type--description', ':description' => t('Exposed description')]);
52 $this->assertEqual(count($result), 1, 'Filter description was found.');