InOperatorTest.php in Drupal 9
File
core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php
View source
<?php
namespace Drupal\Tests\views\Unit\Plugin\filter;
use Drupal\Tests\UnitTestCase;
use Drupal\views\Plugin\views\filter\InOperator;
class InOperatorTest extends UnitTestCase {
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 'string' is not an array for in on filter: ' . $filter
->adminLabel(TRUE), (string) $errors[0]);
}
public static function validate_options_callback() {
return [
'Yes',
'No',
];
}
}