Skip to content
Snippets Groups Projects

Issue #2825860: Fix Notice: Undefined index: value in Drupal\views\Plugin\views\filter\NumericFilter->acceptExposedInput()

Closed Issue #2825860: Fix Notice: Undefined index: value in Drupal\views\Plugin\views\filter\NumericFilter->acceptExposedInput()
5 files
+ 161
27
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -125,11 +125,12 @@ protected function setUp($import_test_views = TRUE, $modules = ['views_test_conf
*/
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');
$filter_identifier = $this->fieldName . '_value';
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_datetime/default/filter/' . $filter_identifier);
$this->submitForm([], 'Expose filter');
$this->submitForm([], 'Grouped filters');
// Test operators with different amount of expected values.
// Create groups with different amount of expected values.
$edit = [];
// No values are required.
$edit['options[group_info][group_items][1][title]'] = 'empty';
@@ -162,24 +163,37 @@ public function testExposedGroupedFilters() {
$this->drupalGet($path);
// Filter the Preview by 'empty'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('1');
$this->getSession()->getPage()->findField($filter_identifier)->selectOption('1');
$this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([4]);
// Filter the Preview by 'not empty'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('2');
$this->getSession()->getPage()->findField($filter_identifier)->selectOption('2');
$this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([1, 2, 3]);
// Filter the Preview by 'less than'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('3');
$this->getSession()->getPage()->findField($filter_identifier)->selectOption('3');
$this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([2, 3]);
// Filter the Preview by 'between'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('4');
$this->getSession()->getPage()->findField($filter_identifier)->selectOption('4');
$this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([2]);
// Change the identifier for grouped exposed filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_datetime/default/filter/' . $filter_identifier);
$filter_identifier = 'date';
$edit['options[group_info][identifier]'] = $filter_identifier;
$this->submitForm($edit, 'Apply');
$this->submitForm([], 'Save');
// Filter results again using a new filter identifier.
$this->drupalGet($path);
$this->getSession()->getPage()->findField($filter_identifier)->selectOption(2);
$this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([1, 2, 3]);
}
/**
@@ -205,7 +219,8 @@ protected function assertIds(array $expected_ids = []): void {
*/
public function testExposedFilterWithPager() {
// 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');
$filter_identifier = $this->fieldName . '_value';
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_datetime/default/filter/' . $filter_identifier);
$this->submitForm([], t('Expose filter'));
$edit = [];
@@ -232,7 +247,7 @@ public function testExposedFilterWithPager() {
// Assert the page with filter in the future, one results without pager.
$page = $this->getSession()->getPage();
$now = \Drupal::time()->getRequestTime();
$page->fillField($this->fieldName . '_value', DrupalDateTime::createFromTimestamp($now + 1)->format('Y-m-d H:i:s'));
$page->fillField($filter_identifier, DrupalDateTime::createFromTimestamp($now + 1)->format('Y-m-d H:i:s'));
$page->pressButton('Apply');
$results = $this->cssSelect('.views-row');
@@ -240,7 +255,7 @@ public function testExposedFilterWithPager() {
$this->assertSession()->pageTextNotContains('Next');
// Assert the page with filter in the past, 3 results with pager.
$page->fillField($this->fieldName . '_value', DrupalDateTime::createFromTimestamp($now - 1000000)->format('Y-m-d H:i:s'));
$page->fillField($filter_identifier, DrupalDateTime::createFromTimestamp($now - 1000000)->format('Y-m-d H:i:s'));
$this->getSession()->getPage()->pressButton('Apply');
$results = $this->cssSelect('.views-row');
$this->assertCount(2, $results);
Loading