public function ExposedFormTest::testInputRequired in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testInputRequired()
- 9 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 299 
Class
- ExposedFormTest
- Tests exposed forms functionality.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testInputRequired() {
  $this
    ->drupalGet('test_exposed_form_buttons_required');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->helperButtonHasLabel('edit-submit-test-exposed-form-buttons-required', 'Apply');
  // Ensure that no results are displayed by default when no input is
  // provided.
  $this
    ->assertSession()
    ->elementNotExists('xpath', "//div[contains(@class, 'views-row')]");
  // Ensure that no error element is shown.
  $this
    ->assertSession()
    ->elementNotExists('css', '.messages--error');
  $this
    ->assertFalse($this
    ->getSession()
    ->getPage()
    ->findField('type')
    ->hasClass('error'));
  $edit = [
    'type' => 'article',
  ];
  $this
    ->submitForm($edit, 'Apply');
  // Ensure that results are displayed by default when input is provided.
  $this
    ->assertSession()
    ->elementsCount('xpath', "//div[contains(@class, 'views-row')]", 5);
  // Test exposed filter on preview.
  $this
    ->drupalGet('admin/structure/views/view/test_view/test_exposed_form_buttons_required');
  $this
    ->assertSession()
    ->elementNotExists('css', '.messages--error');
}