public function FilterInOperatorTest::testFilterOptionAsMarkup in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php \Drupal\Tests\views\Kernel\Handler\FilterInOperatorTest::testFilterOptionAsMarkup()
- 10 core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php \Drupal\Tests\views\Kernel\Handler\FilterInOperatorTest::testFilterOptionAsMarkup()
Tests that the InOperator filter can handle TranslatableMarkup.
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ FilterInOperatorTest.php, line 239
Class
- FilterInOperatorTest
- Tests the core Drupal\views\Plugin\views\filter\InOperator handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testFilterOptionAsMarkup() {
$view = $this
->prophesize(ViewExecutable::class);
$display = $this
->prophesize(DisplayPluginBase::class);
$display
->getOption('relationships')
->willReturn(FALSE);
$view->display_handler = $display
->reveal();
/** @var \Drupal\views\Plugin\ViewsHandlerManager $manager */
$manager = $this->container
->get('plugin.manager.views.filter');
/** @var \Drupal\views\Plugin\views\filter\InOperator $operator */
$operator = $manager
->createInstance('in_operator');
$options = [
'value' => [
'foo' => [],
'baz' => [],
],
];
$operator
->init($view
->reveal(), $display
->reveal(), $options);
$input_options = [
'foo' => 'bar',
'baz' => $this
->t('qux'),
'quux' => (object) [
'option' => [
'quux' => 'corge',
],
],
];
$reduced_values = $operator
->reduceValueOptions($input_options);
$this
->assertSame([
'foo',
'baz',
], array_keys($reduced_values));
$this
->assertInstanceOf(TranslatableMarkup::class, $reduced_values['baz']);
$this
->assertSame('qux', (string) $reduced_values['baz']);
$this
->assertSame('bar', $reduced_values['foo']);
}