Skip to content
Snippets Groups Projects
Verified Commit 9c7fa1c2 authored by Jess's avatar Jess
Browse files

Issue #3323353 by Lendude, ameymudras, VitaliyB98, xjm, andypost: View combine...

Issue #3323353 by Lendude, ameymudras, VitaliyB98, xjm, andypost: View combine filter operator "Is not equal to" use the same operator as "Is equal to"

(cherry picked from commit 981d266c)
parent f24cbd8b
No related branches found
No related tags found
14 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment,!3555Issue #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons,!3494Issue #3327018 by Spokje, longwave, xjm, mondrake: Update PHPStan to 1.9.3 and...,!3410Issue #3340128: UserLoginForm::submitForm has some dead code,!3389Issue #3325184 by Spokje, andypost, xjm, smustgrave: $this->configFactory is...,!3381Issue #3332363: Refactor Claro's menus-and-lists stylesheet,!3307Issue #3326193: CKEditor 5 can grow past the viewport when there is a lot of content,!3236Issue #3332419: Refactor Claro's messages stylesheet,!3231Draft: Issue #3049525 by longwave, fougere, larowlan, kim.pepper, AaronBauman, Wim...,!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28
...@@ -133,7 +133,7 @@ public function validate() { ...@@ -133,7 +133,7 @@ public function validate() {
*/ */
public function opEqual($expression) { public function opEqual($expression) {
$placeholder = $this->placeholder(); $placeholder = $this->placeholder();
$operator = $this->getConditionOperator('LIKE'); $operator = $this->getConditionOperator($this->operator());
$this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]);
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* Tests the combine filter handler. * Tests the combine filter handler.
* *
* @group views * @group views
*
* @coversDefaultClass \Drupal\views\Plugin\views\filter\Combine
*/ */
class FilterCombineTest extends ViewsKernelTestBase { class FilterCombineTest extends ViewsKernelTestBase {
...@@ -283,6 +285,8 @@ public function testNonFieldsRow() { ...@@ -283,6 +285,8 @@ public function testNonFieldsRow() {
/** /**
* Tests the Combine field filter using the 'equal' operator. * Tests the Combine field filter using the 'equal' operator.
*
* @covers::opEqual
*/ */
public function testFilterCombineEqual() { public function testFilterCombineEqual() {
$view = Views::getView('test_view'); $view = Views::getView('test_view');
...@@ -327,6 +331,60 @@ public function testFilterCombineEqual() { ...@@ -327,6 +331,60 @@ public function testFilterCombineEqual() {
$this->assertIdenticalResultset($view, $resultset, $this->columnMap); $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
} }
/**
* Tests the Combine field filter using the 'not equal' operator.
*
* @covers::opEqual
*/
public function testFilterCombineNotEqual(): void {
$view = Views::getView('test_view');
$view->setDisplay();
$fields = $view->displayHandlers->get('default')->getOption('fields');
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
],
]);
// Change the filtering.
$view->displayHandlers->get('default')->overrideOption('filters', [
'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => '!=',
'fields' => [
'job',
],
// The 'I' in 'sInger' is capitalized deliberately because we are
// testing that search filters are case-insensitive.
'value' => 'sInger',
],
]);
$this->executeView($view);
$result_set = [
[
'name' => 'Ringo',
'job' => 'Drummer',
],
[
'name' => 'Paul',
'job' => 'Songwriter',
],
[
'name' => 'Meredith',
'job' => 'Speaker',
],
];
$this->assertIdenticalResultset($view, $result_set, $this->columnMap);
}
/** /**
* Tests the Combine field filter using the 'starts' operator. * Tests the Combine field filter using the 'starts' operator.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment