From 98856bb10ce5701fa27fb34d5b9e53c0ace0d6cc Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Fri, 31 Jul 2020 11:51:17 +1000
Subject: [PATCH] Issue #3074595 by Lendude, ravi.shankar, sime, jian he,
 Kristen Pol, longwave: var_export only returns if the second parameter set to
 TRUE

---
 .../src/Plugin/views/filter/InOperator.php    |  2 +-
 .../src/Unit/Plugin/filter/InOperatorTest.php | 39 +++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php

diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 5fcb23ab14e3..e7ca259940e2 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -451,7 +451,7 @@ public function validate() {
       }
     }
     elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) {
-      $errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', ['@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)]);
+      $errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', ['@value' => var_export($this->value, TRUE), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)]);
     }
     return $errors;
   }
diff --git a/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php b/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php
new file mode 100644
index 000000000000..7f80c6842d77
--- /dev/null
+++ b/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Drupal\Tests\views\Unit\Plugin\filter;
+
+use Drupal\Tests\UnitTestCase;
+use Drupal\views\Plugin\views\filter\InOperator;
+
+/**
+ * @coversDefaultClass \Drupal\views\Plugin\views\filter\InOperator
+ * @group views
+ */
+class InOperatorTest extends UnitTestCase {
+
+  /**
+   * @covers ::validate
+   */
+  public function testValidate() {
+    $definition = [
+      'title' => 'Is InOperator Test',
+      'group' => 'Test',
+      'options callback' => '\Drupal\Tests\views\Unit\Plugin\filter\InOperatorTest::validate_options_callback',
+    ];
+    $filter = new InOperator([], 'in_operator', $definition);
+    $filter->value = 'string';
+    $filter->operator = 'in';
+    $translation_stub = $this->getStringTranslationStub();
+    $filter->setStringTranslation($translation_stub);
+    $errors = $filter->validate();
+    $this->assertSame('The value &#039;string&#039; is not an array for in on filter: ' . $filter->adminLabel(TRUE), (string) $errors[0]);
+  }
+
+  /**
+   * @return array
+   */
+  public static function validate_options_callback() {
+    return ['Yes', 'No'];
+  }
+
+}
-- 
GitLab