diff --git a/core/modules/field/src/Tests/String/RawStringFormatterTest.php b/core/modules/field/src/Tests/String/RawStringFormatterTest.php index 60ea420..c175a22 100644 --- a/core/modules/field/src/Tests/String/RawStringFormatterTest.php +++ b/core/modules/field/src/Tests/String/RawStringFormatterTest.php @@ -124,6 +124,11 @@ public function testStringFormatter() { // Verify the cache tags. $build = $entity->{$this->fieldName}->view(); $this->assertTrue(!isset($build[0]['#cache']), 'The string formatter has no cache tags.'); + + // Verify the render array of the field formatter. + $this->assertIdentical($build[0]['#type'], 'inline_template'); + $this->assertIdentical($build[0]['#template'], '{{ value|nl2br }}'); + $this->assertIdentical($build[0]['#context']['value'], $value); } } diff --git a/core/modules/field/src/Tests/String/UuidFormatterTest.php b/core/modules/field/src/Tests/String/UuidFormatterTest.php index 50ed4bf..fbd51d1 100644 --- a/core/modules/field/src/Tests/String/UuidFormatterTest.php +++ b/core/modules/field/src/Tests/String/UuidFormatterTest.php @@ -46,15 +46,23 @@ public function testUuidStringFormatter() { $uuid_field = $entity->get('uuid'); + // Verify default build and render. $render_array = $uuid_field->view([]); - $value = $this->render($render_array); - $this->assertTrue(strpos($value, $entity->uuid()), 'The rendered UUID matches the entity UUID.'); + $this->assertIdentical($render_array[0]['#type'], 'inline_template'); + $this->assertIdentical($render_array[0]['#template'], '{{ value|nl2br }}'); + $this->assertIdentical($render_array[0]['#context']['value'], $entity->uuid()); + $this->assertTrue(strpos($this->render($render_array), $entity->uuid()), 'The rendered UUID found.'); + // Verify customized build and render. $render_array = $uuid_field->view(['settings' => ['link_to_entity' => TRUE]]); $this->assertIdentical($render_array[0]['#type'], 'link'); + $this->assertIdentical($render_array[0]['#title']['#type'], 'inline_template'); + $this->assertIdentical($render_array[0]['#title']['#template'], '{{ value|nl2br }}'); + $this->assertIdentical($render_array[0]['#title']['#context']['value'], $entity->uuid()); $this->assertIdentical($render_array[0]['#url']->toString(), $entity->url()); - $value = $this->render($render_array); - $this->assertTrue(strpos($value, $entity->uuid())); + $rendered = $this->render($render_array); + $this->assertTrue(strpos($rendered, $entity->uuid()), 'The rendered UUID found.'); + $this->assertTrue(strpos($rendered, $entity->url()), 'The rendered entity URL found.'); } }