Loading core/modules/views/src/Plugin/views/filter/NumericFilter.php +2 −2 Changes for core/modules/views/src/Plugin/views/filter/NumericFilter.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ function operators() { 'regular_expression' => array( 'title' => $this->t('Regular expression'), 'short' => $this->t('regex'), 'method' => 'op_regex', 'method' => 'opRegex', 'values' => 1, ), ); Loading Loading @@ -274,7 +274,7 @@ protected function opEmpty($field) { * The expression pointing to the queries field, for example "foo.bar". */ protected function opRegex($field) { $this->query->addWhere($this->options['group'], $field, $this->value, 'REGEXP'); $this->query->addWhere($this->options['group'], $field, $this->value['value'], 'REGEXP'); } public function adminSummary() { Loading core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php +67 −0 Changes for core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php: 67 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -212,6 +212,66 @@ public function testFilterNumericExposedGroupedNotBetween() { $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } /** * Tests the numeric filter handler with the 'regular_expression' operator. */ public function testFilterNumericRegularExpression() { $view = Views::getView('test_view'); $view->setDisplay(); // Filtering by regular expression pattern. $view->displayHandlers->get('default')->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', 'field' => 'age', 'relationship' => 'none', 'operator' => 'regular_expression', 'value' => array( 'value' => '2[8]', ), ), )); $this->executeView($view); $resultset = array( array( 'name' => 'Ringo', 'age' => 28, ), ); $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } /** * Tests the numeric filter handler with the 'regular_expression' operator * to grouped exposed filters. */ public function testFilterNumericExposedGroupedRegularExpression() { $filters = $this->getGroupedExposedFilters(); $view = Views::getView('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: regular_expression, Value: 2[7-8] $filters['age']['group_info']['default_group'] = 6; $view->setDisplay('page_1'); $view->displayHandlers->get('page_1')->overrideOption('filters', $filters); $view->save(); $this->executeView($view); $resultset = array( array( 'name' => 'George', 'age' => 27, ), array( 'name' => 'Ringo', 'age' => 28, ), ); $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } public function testFilterNumericEmpty() { $view = Views::getView('test_view'); $view->setDisplay(); Loading Loading @@ -407,6 +467,13 @@ protected function getGroupedExposedFilters() { 'title' => 'Age is not empty', 'operator' => 'not empty', ), 6 => array( 'title' => 'Age is regexp 2[7-8]', 'operator' => 'regular_expression', 'value' => array( 'value' => '2[7-8]', ), ), ), ), ), Loading Loading
core/modules/views/src/Plugin/views/filter/NumericFilter.php +2 −2 Changes for core/modules/views/src/Plugin/views/filter/NumericFilter.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ function operators() { 'regular_expression' => array( 'title' => $this->t('Regular expression'), 'short' => $this->t('regex'), 'method' => 'op_regex', 'method' => 'opRegex', 'values' => 1, ), ); Loading Loading @@ -274,7 +274,7 @@ protected function opEmpty($field) { * The expression pointing to the queries field, for example "foo.bar". */ protected function opRegex($field) { $this->query->addWhere($this->options['group'], $field, $this->value, 'REGEXP'); $this->query->addWhere($this->options['group'], $field, $this->value['value'], 'REGEXP'); } public function adminSummary() { Loading
core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php +67 −0 Changes for core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php: 67 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -212,6 +212,66 @@ public function testFilterNumericExposedGroupedNotBetween() { $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } /** * Tests the numeric filter handler with the 'regular_expression' operator. */ public function testFilterNumericRegularExpression() { $view = Views::getView('test_view'); $view->setDisplay(); // Filtering by regular expression pattern. $view->displayHandlers->get('default')->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', 'field' => 'age', 'relationship' => 'none', 'operator' => 'regular_expression', 'value' => array( 'value' => '2[8]', ), ), )); $this->executeView($view); $resultset = array( array( 'name' => 'Ringo', 'age' => 28, ), ); $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } /** * Tests the numeric filter handler with the 'regular_expression' operator * to grouped exposed filters. */ public function testFilterNumericExposedGroupedRegularExpression() { $filters = $this->getGroupedExposedFilters(); $view = Views::getView('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: regular_expression, Value: 2[7-8] $filters['age']['group_info']['default_group'] = 6; $view->setDisplay('page_1'); $view->displayHandlers->get('page_1')->overrideOption('filters', $filters); $view->save(); $this->executeView($view); $resultset = array( array( 'name' => 'George', 'age' => 27, ), array( 'name' => 'Ringo', 'age' => 28, ), ); $this->assertIdenticalResultset($view, $resultset, $this->columnMap); } public function testFilterNumericEmpty() { $view = Views::getView('test_view'); $view->setDisplay(); Loading Loading @@ -407,6 +467,13 @@ protected function getGroupedExposedFilters() { 'title' => 'Age is not empty', 'operator' => 'not empty', ), 6 => array( 'title' => 'Age is regexp 2[7-8]', 'operator' => 'regular_expression', 'value' => array( 'value' => '2[7-8]', ), ), ), ), ), Loading