function ExposedFormTest::testInputRequired

Same name and namespace in other branches
  1. 8.9.x 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()

Tests the input required exposed form type.

File

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

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 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.