diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index 36d4fb6..81084f9 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -376,9 +376,9 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co $views_field['help'] = $description; } else { - // No description set on the field definition. Use the field's label as - // fallback description. If a better description should be used just for - // Views UI you can use hook_views_data_alter() in a module.views.inc file + // No description set on the field definition. If a better description + // should be used just for Views UI you can use hook_views_data_alter() in + // a module.views.inc file. // @see node_views_data_alter(). $views_field['help'] = " "; } diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php index 214397a..627c725 100644 --- a/core/modules/views_ui/src/Tests/HandlerTest.php +++ b/core/modules/views_ui/src/Tests/HandlerTest.php @@ -65,7 +65,9 @@ protected function schemaDefinition() { /** * Overrides \Drupal\views\Tests\ViewTestBase::viewsData(). * - * Adds a relationship for the uid column. + * Adds: + * - a relationship for the uid column. + * - a dummy field with no help text. */ protected function viewsData() { $data = parent::viewsData(); @@ -79,6 +81,12 @@ protected function viewsData() { ) ); + // Create a dummy field with no help text. + $data['views_test_data']['no_help'] = $data['views_test_data']['name']; + $data['views_test_data']['no_help']['field']['title'] = t('No help'); + $data['views_test_data']['no_help']['field']['real field'] = 'name'; + unset($data['views_test_data']['no_help']['help']); + return $data; } @@ -247,6 +255,24 @@ public function testNoDuplicateFields() { } /** + * Ensures that the Error: missing help message is not shown for entity + * field handlers but is shown for other field handlers, + * + * @see \Drupal\views\EntityViewsData + */ + public function testErrorMissingHelp() { + // Test that the error message is not shown for entity fields but an empty + // description field is shown instead. + $this->drupalGet('admin/structure/views/nojs/add-handler/test_node_view/default/field'); + $this->assertNoText('Error: missing help'); + $this->assertTrue(count($this->xpath('//td[contains(@class, description) and text()=" "]')), 'Empty description found'); + + // Test that error message is shown for other fields. + $this->drupalGet('admin/structure/views/nojs/add-handler/test_view_empty/default/field'); + $this->assertText('Error: missing help'); + } + + /** * Asserts that fields only appear once. * * @param string $field_name