You are here

public function InOperatorTest::testValidate in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php \Drupal\Tests\views\Unit\Plugin\filter\InOperatorTest::testValidate()
  2. 9 core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php \Drupal\Tests\views\Unit\Plugin\filter\InOperatorTest::testValidate()

@covers ::validate

File

core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php, line 17

Class

InOperatorTest
@coversDefaultClass \Drupal\views\Plugin\views\filter\InOperator @group views

Namespace

Drupal\Tests\views\Unit\Plugin\filter

Code

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]);
}