public function FilterDateTest::testExposedGroupedFilters in Drupal 9
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Functional/Views/FilterDateTest.php \Drupal\Tests\datetime\Functional\Views\FilterDateTest::testExposedGroupedFilters()
- 10 core/modules/datetime/tests/src/Functional/Views/FilterDateTest.php \Drupal\Tests\datetime\Functional\Views\FilterDateTest::testExposedGroupedFilters()
Tests exposed grouped filters.
File
- core/
modules/ datetime/ tests/ src/ Functional/ Views/ FilterDateTest.php, line 118
Class
- FilterDateTest
- Tests Views filters for datetime fields.
Namespace
Drupal\Tests\datetime\Functional\ViewsCode
public function testExposedGroupedFilters() {
// Expose the empty and not empty operators in a grouped filter.
$this
->drupalGet('admin/structure/views/nojs/handler/test_filter_datetime/default/filter/' . $this->fieldName . '_value');
$this
->submitForm([], 'Expose filter');
$this
->submitForm([], 'Grouped filters');
$edit = [];
$edit['options[group_info][group_items][1][title]'] = 'empty';
$edit['options[group_info][group_items][1][operator]'] = 'empty';
$edit['options[group_info][group_items][2][title]'] = 'not empty';
$edit['options[group_info][group_items][2][operator]'] = 'not empty';
$this
->submitForm($edit, 'Apply');
// Test that the exposed filter works as expected.
$path = 'test_filter_datetime-path';
$this
->drupalGet('admin/structure/views/view/test_filter_datetime/edit');
$this
->submitForm([], 'Add Page');
$this
->drupalGet('admin/structure/views/nojs/display/test_filter_datetime/page_1/path');
$this
->submitForm([
'path' => $path,
], 'Apply');
$this
->submitForm([], 'Save');
$this
->drupalGet($path);
// Filter the Preview by 'empty'.
$this
->getSession()
->getPage()
->findField($this->fieldName . '_value')
->selectOption(1);
$this
->getSession()
->getPage()
->pressButton('Apply');
$results = $this
->cssSelect('.view-content .field-content');
$this
->assertCount(1, $results);
// Filter the Preview by 'not empty'.
$this
->getSession()
->getPage()
->findField($this->fieldName . '_value')
->selectOption(2);
$this
->getSession()
->getPage()
->pressButton('Apply');
$results = $this
->cssSelect('.view-content .field-content');
$this
->assertCount(3, $results);
}