diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 2752729..53d287f 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -251,3 +251,17 @@ function entity_test_entity_test_insert($entity) { throw new Exception("Test exception rollback."); } } + +/** + * Implements hook_entity_view_mode_info(). + */ +function entity_test_entity_view_mode_info() { + $view_modes['entity_test_render']['full'] = array( + 'label' => t('Full'), + ); + $view_modes['entity_test_render']['test'] = array( + 'label' => t('Test'), + ); + + return $view_modes; +} diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php index 24dbd4d..a333fa9 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php @@ -26,6 +26,12 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang $entity->content['label'] = array( '#markup' => check_plain($entity->label()), ); + $entity->content['separator'] = array( + '#markup' => ' | ', + ); + $entity->content['view_mode'] = array( + '#markup' => check_plain($view_mode), + ); } } 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 b5dc005..cf19ab1 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -86,7 +86,21 @@ public function testEntityArea() { $this->drupalSetContent($view->preview()); $result = $this->xpath('//div[@class = "view-header"]'); - $this->assertEqual(trim((string) $result[0]), $random_label, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), $random_label) !== FALSE, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); + + // Change the view mode of the area handler. + $view = views_get_view('test_entity_area'); + $item = $view->getItem('default', 'header', 'entity_entity_test_render'); + $item['view_mode'] = 'test'; + $view->setItem('default', 'header', 'entity_entity_test_render', $item); + + $this->drupalSetContent($view->preview()); + + $result = $this->xpath('//div[@class = "view-header"]'); + $this->assertTrue(strpos(trim((string) $result[0]), $random_label) !== FALSE, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), 'test') !== FALSE, 'The rendered entity appeared in the right view mode.'); + } } diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml index f8f69d3..c81db20 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml @@ -11,7 +11,7 @@ display: pager_options: '0' sorts: '0' header: - entity_node: + entity_entity_test_render: field: entity_entity_test_render id: entity_entity_test_render table: views