// Combined field filter only works with fields that are in the field
// settings.
$errors[]=$this->t('Field %field set in %filter is not set in this display.',array('%field'=>$id,'%filter'=>$this->adminLabel()));
break;
}
elseif(!$fields[$id]->clickSortable()){
// Combined field filter only works with simple fields. If the field is
// not click sortable we can assume it is not a simple field.
// @todo change this check to isComputed. See
// https://www.drupal.org/node/2349465
$errors[]=$this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.',array('%field'=>$fields[$id]->adminLabel(),'%filter'=>$this->adminLabel()));
// Combined field filter only works with fields that are in the field
// settings.
$errors[]=$this->t('Field %field set in %filter is not set in display %display.',array('%field'=>$id,'%filter'=>$this->adminLabel(),'%display'=>$this->displayHandler->display['display_title']));
break;
}
elseif(!$fields[$id]->clickSortable()){
// Combined field filter only works with simple fields. If the field
// is not click sortable we can assume it is not a simple field.
// @todo change this check to isComputed. See
// https://www.drupal.org/node/2349465
$errors[]=$this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.',array('%field'=>$fields[$id]->adminLabel(),'%filter'=>$this->adminLabel()));
}
}
}
else{
$errors[]=$this->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.',array('%display'=>$this->displayHandler->display['display_title'],'%filter'=>$this->adminLabel()));
@@ -29,6 +34,15 @@ class FilterCombineTest extends ViewsKernelTestBase {
'views_test_data_job'=>'job',
);
/**
* {@inheritdoc}
*/
protectedfunctionsetUp($import_test_views=TRUE){
parent::setUp($import_test_views);
$this->installEntitySchema('entity_test');
}
publicfunctiontestFilterCombineContains(){
$view=Views::getView('test_view');
$view->setDisplay();
...
...
@@ -126,7 +140,42 @@ public function testFilterCombineContainsFieldsOverwritten() {
$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->assertEqual(reset($errors['default']),t('Field %field set in %filter is not set in this display.',array('%field'=>'dummy','%filter'=>'Global: Combine fields filter')));
$this->assertEquals(t('Field %field set in %filter is not set in display %display.',array('%field'=>'dummy','%filter'=>'Global: Combine fields filter','%display'=>'Master')),reset($errors['default']));
}
/**
* Tests that the combine field filter is not valid on displays that don't use
* fields.
*/
publicfunctiontestNonFieldsRow(){
$view=Views::getView('entity_test_fields');
$view->setDisplay();
// Set the rows to a plugin type that doesn't support fields.
$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.',array('%filter'=>'Global: Combine fields filter','%display'=>'Master')),reset($errors['default']));