@sun in #1857376: Provide an area handler that renders an entity:

+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php

+  public function testEntityArea() {
...
+    $result = $this->xpath('//div[@class = "view-header"]');
+    $this->assertTrue(strpos(trim((string) $result[0]), $entities[0]->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.');
+
+    $result = $this->xpath('//div[@class = "view-footer"]');
+    $this->assertTrue(strpos(trim((string) $result[0]), $entities[1]->label()) !== FALSE, 'The rendered entity appears in the header of the view.');


+++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml

+      header:
...
+          entity_id: 1
...
+      footer:
...
+          entity_id: !1

A hidden gem in the footer area entity_id.

Should the tests have passed? Depends on whether entity_test entity IDs are integers, and whether 0 is a valid entity ID.

> php -r "var_dump((int) '!1');"
int(0)

Comments

dawehner’s picture

Status: Active » Fixed

Copied from http://drupal.org/node/1857376#comment-7237924

@sun

The entity area handler allows you to replace tokens by arguments from the url/passed into the view. So !1 stands for the first argument of the view.

$this->drupalSetContent($view->preview('default', array($entities[1]->id())));

$result = $this->xpath('//div[@class = "view-footer"]');
    $this->assertTrue(strpos(trim((string) $result[0]), $entities[1]->label()) !== FALSE, 'The rendered entity appears in the header of the view.');

So we check here that the token got replaced with the actual right ID and then the full entity is loaded.

From my perspective this doesn't seem to be an issue, feel free to reopen if you think I'm wrong.

Automatically closed -- issue fixed for 2 weeks with no activity.