Unverified Commit 98856bb1 authored by larowlan's avatar larowlan

Issue #3074595 by Lendude, ravi.shankar, sime, jian he, Kristen Pol, longwave:...

Issue #3074595 by Lendude, ravi.shankar, sime, jian he, Kristen Pol, longwave: var_export only returns if the second parameter set to TRUE
parent ff722653
......@@ -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;
}
......
<?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'];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment