function FilterCombineTest::testNonFieldsRow
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testNonFieldsRow()
- 10 core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testNonFieldsRow()
- 11.x core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testNonFieldsRow()
Tests that the combine field filter is not valid on displays that don't use fields.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ FilterCombineTest.php, line 249
Class
- FilterCombineTest
- Tests the combine filter handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testNonFieldsRow() {
$view = Views::getView('entity_test_fields');
$view->setDisplay();
// Set the rows to a plugin type that doesn't support fields.
$view->displayHandlers
->get('default')
->overrideOption('row', [
'type' => 'entity:entity_test',
'options' => [
'view_mode' => 'teaser',
],
]);
// Change the filtering.
$view->displayHandlers
->get('default')
->overrideOption('filters', [
'name' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'contains',
'fields' => [
'name',
],
'value' => 'ing',
],
]);
$this->executeView($view);
$errors = $view->validate();
// Check that the right error is shown.
$this->assertEquals(t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', [
'%filter' => 'Global: Combine fields filter',
'%display' => 'Master',
]), reset($errors['default']));
// Confirm that the query with single filter does not use the "CONCAT_WS"
// operator.
$this->assertStringNotContainsString('CONCAT_WS(', $view->query
->query());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.