diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php index b94b944..af628d9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -46,10 +46,37 @@ protected function setUp() { } /** + * Tests views data for entity area handlers. + */ + public function testEntityAreaData() { + $data = drupal_container()->get('views.views_data')->get('views'); + $entity_info = entity_get_info(); + + $expected_entities = array_filter($entity_info, function($info) { + return !is_subclass_of($info['class'], 'Drupal\Core\Config\Entity\ConfigEntityInterface'); + }); + + // Test that all expected entity types have data. + foreach (array_keys($expected_entities) as $entity) { + $this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', array('@entity' => $entity))); + // Test that entity_type is set correctly in the area data. + $this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', array('@entity' => $entity))); + } + + $expected_entities = array_filter($entity_info, function($info) { + return is_subclass_of($info['class'], 'Drupal\Core\Config\Entity\ConfigEntityInterface'); + }); + + // Test that no configuration entity types have data. + foreach (array_keys($expected_entities) as $entity) { + $this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', array('@entity' => $entity))); + } + } + + /** * Tests the area handler. */ public function testEntityArea() { - // @todo The entity_test entity isn't rendered so let's use node. $entity_test = $this->drupalCreateNode(); $view = views_get_view('test_entity_area'); diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 24d6975..f42ac09 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -106,14 +106,15 @@ function views_views_data() { ), ); - // Registers on area per entity type. + // Registers an entity area handler per entity type. foreach (entity_get_info() as $entity_type => $entity_info) { - // Views already have a custom area handler. - if ($entity_type != 'views') { + // Configuration entities are also not needed here. Views already has a + // custom area handler. + if (!is_subclass_of($entity_info['class'], 'Drupal\Core\Config\Entity\ConfigEntityInterface')) { $label = $entity_info['label']; $data['views']['entity_' . $entity_type] = array( - 'title' => t('Rendered @entity_label', array('@entity_label' => $label)), - 'help' => t('Shows an @label in the area.', array('@label' => $label)), + 'title' => t('Rendered entity - @label', array('@label' => $label)), + 'help' => t('Displays a rendered @label entity in an area.', array('@label' => $label)), 'area' => array( 'entity_type' => $entity_type, 'id' => 'entity',