function FilterDateTest::testExposedGroupedFilters
Same name in other branches
- 9 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()
- 11.x 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->drupalPostForm('admin/structure/views/nojs/handler/test_filter_datetime/default/filter/' . $this->fieldName . '_value', [], t('Expose filter'));
$this->drupalPostForm(NULL, [], '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->drupalPostForm(NULL, $edit, 'Apply');
// Test that the exposed filter works as expected.
$path = 'test_filter_datetime-path';
$this->drupalPostForm('admin/structure/views/view/test_filter_datetime/edit', [], 'Add Page');
$this->drupalPostForm('admin/structure/views/nojs/display/test_filter_datetime/page_1/path', [
'path' => $path,
], 'Apply');
$this->drupalPostForm(NULL, [], t('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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.