function ExposedFilterAJAXTest::testExposedFiltering
Same name and namespace in other branches
- 9 core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltering()
- 8.9.x core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltering()
- 10 core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltering()
Tests if exposed filtering via AJAX works for the "Content" View.
File
-
core/
modules/ views/ tests/ src/ FunctionalJavascript/ ExposedFilterAJAXTest.php, line 80
Class
- ExposedFilterAJAXTest
- Tests the basic AJAX functionality of Views exposed forms.
Namespace
Drupal\Tests\views\FunctionalJavascriptCode
public function testExposedFiltering() : void {
// Visit the View page.
$this->drupalGet('admin/content');
$session = $this->getSession();
// Ensure that the Content we're testing for is present.
$html = $session->getPage()
->getHtml();
$this->assertStringContainsString('Page One', $html);
$this->assertStringContainsString('Page Two', $html);
// Search for "Page One".
$this->submitForm([
'title' => 'Page One',
], 'Filter');
$this->assertSession()
->assertWaitOnAjaxRequest();
// Verify that only the "Page One" Node is present.
$html = $session->getPage()
->getHtml();
$this->assertStringContainsString('Page One', $html);
$this->assertStringNotContainsString('Page Two', $html);
// Search for "Page Two".
$this->submitForm([
'title' => 'Page Two',
], 'Filter');
$this->assertSession()
->assertWaitOnAjaxRequest();
// Verify that only the "Page Two" Node is present.
$html = $session->getPage()
->getHtml();
$this->assertStringContainsString('Page Two', $html);
$this->assertStringNotContainsString('Page One', $html);
// Submit bulk actions form to ensure that the previous AJAX submit does not
// break it.
$this->submitForm([
'action' => 'node_make_sticky_action',
'node_bulk_form[0]' => TRUE,
], 'Apply to selected items');
// Verify that the action was performed.
$this->assertSession()
->pageTextContains('Make content sticky was applied to 1 item.');
// Reset the form.
$this->submitForm([], 'Reset');
$this->assertSession()
->pageTextContains('Page One');
$this->assertSession()
->pageTextContains('Page Two');
$this->assertFalse($session->getPage()
->hasButton('Reset'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.