function FilterCombineTest::testFilterCombineContainsFieldsOverwritten
Same name in other branches
- 8.9.x core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testFilterCombineContainsFieldsOverwritten()
- 10 core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testFilterCombineContainsFieldsOverwritten()
- 11.x core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testFilterCombineContainsFieldsOverwritten()
Tests if the filter can handle removed fields.
Tests the combined filter handler when a field overwrite is done and fields set in the combine filter are removed from the display but not from the combined filter settings.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ FilterCombineTest.php, line 206
Class
- FilterCombineTest
- Tests the combine filter handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testFilterCombineContainsFieldsOverwritten() {
$view = Views::getView('test_view');
$view->setDisplay();
$fields = $view->displayHandlers
->get('default')
->getOption('fields');
$view->displayHandlers
->get('default')
->overrideOption('fields', $fields + [
'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
],
]);
// Change the filtering.
$view->displayHandlers
->get('default')
->overrideOption('filters', [
'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'contains',
'fields' => [
'name',
'job',
// Add a dummy field to the combined fields to simulate
// a removed or deleted field.
'dummy',
],
'value' => 'ing',
],
]);
$this->executeView($view);
// Make sure this view will not get displayed.
$this->assertTrue($view->build_info['fail'], "View build has been marked as failed.");
// Make sure this view does not pass validation with the right error.
$errors = $view->validate();
$this->assertEquals(t('Field %field set in %filter is not set in display %display.', [
'%field' => 'dummy',
'%filter' => 'Global: Combine fields filter',
'%display' => 'Default',
]), reset($errors['default']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.