function ExposedFormTest::testInputRequired

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testInputRequired()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testInputRequired()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testInputRequired()

Tests the input required exposed form type.

1 call to ExposedFormTest::testInputRequired()
ExposedFormTest::testExposedForm in core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
Tests the input required exposed form type.

File

core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php, line 345

Class

ExposedFormTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

protected function testInputRequired() : void {
  $view = View::load('test_exposed_form_buttons');
  $display =& $view->getDisplay('default');
  $display['display_options']['exposed_form']['type'] = 'input_required';
  $view->save();
  $this->drupalGet('test_exposed_form_buttons');
  $this->assertSession()
    ->statusCodeEquals(200);
  $this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', 'Apply');
  // Ensure that no results are displayed by default when no input is
  // provided.
  $this->assertSession()
    ->elementNotExists('xpath', "//div[contains(@class, 'views-row')]");
  $this->drupalGet('test_exposed_form_buttons', [
    'query' => [
      'type' => 'article',
    ],
  ]);
  // Ensure that results are displayed by default when input is provided.
  $this->assertSession()
    ->elementsCount('xpath', "//div[contains(@class, 'views-row')]", 5);
}

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