You are here

public function ExposedFormTest::testFormErrorWithExposedForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testFormErrorWithExposedForm()

Tests a view which is rendered after a form with a validation error.

File

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

Class

ExposedFormTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testFormErrorWithExposedForm() {
  $this
    ->drupalGet('views_test_data_error_form_page');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $form = $this
    ->cssSelect('form.views-exposed-form');
  $this
    ->assertNotEmpty($form, 'The exposed form element was found.');

  // Ensure the exposed form is rendered before submitting the normal form.
  $this
    ->assertSession()
    ->responseContains("Apply");
  $this
    ->assertSession()
    ->responseContains('<div class="views-row">');
  $this
    ->submitForm([], 'Submit');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $form = $this
    ->cssSelect('form.views-exposed-form');
  $this
    ->assertNotEmpty($form, 'The exposed form element was found.');

  // Ensure the exposed form is rendered after submitting the normal form.
  $this
    ->assertSession()
    ->responseContains("Apply");
  $this
    ->assertSession()
    ->responseContains('<div class="views-row">');
}