function DateFilterTest::testLimitExposedOperators
Same name in other branches
- 9 core/modules/datetime/tests/src/Functional/DateFilterTest.php \Drupal\Tests\datetime\Functional\DateFilterTest::testLimitExposedOperators()
- 8.9.x core/modules/datetime/tests/src/Functional/DateFilterTest.php \Drupal\Tests\datetime\Functional\DateFilterTest::testLimitExposedOperators()
- 10 core/modules/datetime/tests/src/Functional/DateFilterTest.php \Drupal\Tests\datetime\Functional\DateFilterTest::testLimitExposedOperators()
Tests the limit of the expose operator functionality.
File
-
core/
modules/ datetime/ tests/ src/ Functional/ DateFilterTest.php, line 85
Class
- DateFilterTest
- Test exposed datetime filters functionality.
Namespace
Drupal\Tests\datetime\FunctionalCode
public function testLimitExposedOperators() : void {
$this->drupalGet('test_exposed_filter_datetime');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->optionExists('edit-field-date-value-op', '=');
$this->assertSession()
->optionNotExists('edit-field-date-value-op', '>');
$this->assertSession()
->optionNotExists('edit-field-date-value-op', '>=');
// Because there are not operators that use the min and max fields, those
// fields should not be in the exposed form.
$this->assertSession()
->fieldExists('edit-field-date-value-value');
$this->assertSession()
->fieldNotExists('edit-field-date-value-min');
$this->assertSession()
->fieldNotExists('edit-field-date-value-max');
$edit = [];
$edit['options[operator]'] = '>';
$edit['options[expose][operator_list][]'] = [
'>',
'>=',
'between',
];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_filter_datetime/default/filter/field_date_value');
$this->submitForm($edit, 'Apply');
$this->drupalGet('admin/structure/views/view/test_exposed_filter_datetime/edit/default');
$this->submitForm([], 'Save');
$this->drupalGet('test_exposed_filter_datetime');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->optionNotExists('edit-field-date-value-op', '<');
$this->assertSession()
->optionNotExists('edit-field-date-value-op', '<=');
$this->assertSession()
->optionNotExists('edit-field-date-value-op', '=');
$this->assertSession()
->optionExists('edit-field-date-value-op', '>');
$this->assertSession()
->optionExists('edit-field-date-value-op', '>=');
$this->assertSession()
->fieldExists('edit-field-date-value-value');
$this->assertSession()
->fieldExists('edit-field-date-value-min');
$this->assertSession()
->fieldExists('edit-field-date-value-max');
// Set the default to an excluded operator.
$edit = [];
$edit['options[operator]'] = '=';
$edit['options[expose][operator_list][]'] = [
'<',
'>',
];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_filter_datetime/default/filter/field_date_value');
$this->submitForm($edit, 'Apply');
$this->assertSession()
->pageTextContains('You selected the "Is equal to" operator as the default value but is not included in the list of limited operators.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.