From 0e70a5f9799b4ad022bc967bd045848f866fad5f Mon Sep 17 00:00:00 2001
From: amontero <amontero@166637.no-reply.drupal.org>
Date: Sun, 12 Aug 2012 19:55:38 +0200
Subject: [PATCH] Basic token support in fields' help texts

Basic token support in fields' help texts
---
 .../field/lib/Drupal/field/Tests/FormTest.php      |    6 +++++-
 .../Drupal/image/Tests/ImageFieldDisplayTest.php   |    3 +++
 .../lib/Drupal/image/Tests/ImageFieldTestBase.php  |    1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index 3e79eda..b2759c8 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -38,7 +38,7 @@ class FormTest extends FieldTestBase {
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'description' => '[site:name]_description',
       'weight' => mt_rand(0, 127),
       'settings' => array(
         'test_instance_setting' => $this->randomName(),
@@ -63,6 +63,10 @@ class FormTest extends FieldTestBase {
 
     // Display creation form.
     $this->drupalGet('test-entity/add/test_bundle');
+
+    // Create token value expected for description.
+    $token_description = check_plain(variable_get('site_name', 'Drupal')) . '_description';
+    $this->assertText($token_description, 'Token replacement for description is displayed');
     $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed');
     $this->assertNoField("{$this->field_name}[$langcode][1][value]", 'No extraneous widget is displayed');
     // TODO : check that the widget is populated with default value ?
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
index 39eb53b..8545bdb 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
@@ -133,6 +133,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
       'max_resolution' => '100x100',
       'min_resolution' => '10x10',
       'title_field' => 1,
+      'description' => '[site:name]_description',
     );
     $widget_settings = array(
       'preview_image_style' => 'medium',
@@ -144,6 +145,8 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
     $instance = field_info_instance('node', $field_name, 'article');
 
     $this->drupalGet('node/add/article');
+    $token_description = check_plain(variable_get('site_name', 'Drupal')) . '_description';
+    $this->assertText($token_description, 'Token replacement for description is displayed on article form.');
     $this->assertText(t('Files must be less than 50 KB.'), t('Image widget max file size is displayed on article form.'));
     $this->assertText(t('Allowed file types: ' . $test_image_extension . '.'), t('Image widget allowed file types displayed on article form.'));
     $this->assertText(t('Images must be between 10x10 and 100x100 pixels.'), t('Image widget allowed resolution displayed on article form.'));
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
index e78a364..d9de6ed 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
@@ -86,6 +86,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
       'label' => $name,
       'bundle' => $type_name,
       'required' => !empty($instance_settings['required']),
+      'description' => !empty($instance_settings['description']) ? $instance_settings['description'] : '',
       'settings' => array(),
       'widget' => array(
         'type' => 'image_image',
-- 
1.7.9.5

