function ExposedFormTest::testInputRequired

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testInputRequired()
  2. 10 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()

Test the input required exposed form type.

File

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

Class

ExposedFormTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testInputRequired() {
    $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.
    $rows = $this->xpath("//div[contains(@class, 'views-row')]");
    $this->assertCount(0, $rows, 'No rows are displayed by default when no input is provided.');
    $this->drupalGet('test_exposed_form_buttons', [
        'query' => [
            'type' => 'article',
        ],
    ]);
    // Ensure that results are displayed.
    $rows = $this->xpath("//div[contains(@class, 'views-row')]");
    $this->assertCount(5, $rows, 'All rows are displayed by default when input is provided.');
}

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