commit 3aa8ae4e7f75f79baa666f0949793eb1b212893c
Author: Steve Oliver <steve@circatree.com>
Date:   Mon Jun 17 12:45:52 2013 -0700

    Add test for links. Clean up.

diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwigDrillable.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwigDrillable.php
index 8d5ab0b..5c54864 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwigDrillable.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwigDrillable.php
@@ -20,7 +20,7 @@ class ThemeTestTwigDrillable extends WebTestBase {
    *
    * @var array
    */
-  public static $modules = array('node', 'image', 'field_ui');
+  public static $modules = array('node', 'image', 'field_ui', 'twig_theme_test');
 
   public static function getInfo() {
     return array(
@@ -126,26 +126,28 @@ function uploadNodeImage($image, $field_name, $type) {
   }
 
   /**
-   * Test twig node template offers drillable field variables.
+   * Test that render element variables are available to Twig templates.
    */
-  function testTwigDrillableNodeTemplateFields() {
+  function testTwigDrillableElements() {
     config('system.theme')
       ->set('default', 'test_drillable')
       ->save();
-    // Create a new node with an image attached.
+
+    // Access render array children.
+    $this->drupalGet('twig-theme-test/drillable-elements');
+    $customized_link = $this->xpath('//a[@href="/links/link-1" and @cardinality="first"]');
+    $this->assertTrue(count($customized_link) === 1, 'Twig template can access variables prepared for child elements.');
+
+    // Access field instances.
     $field_name = 'field_image';
     $this->createImageField($field_name, 'article', array('uri_scheme' => 'public'));
-
     $test_image = current($this->drupalGetTestFiles('image'));
     $nid = $this->uploadNodeImage($test_image, $field_name, 'article');
-
     $this->drupalGet('node/' . $nid);
     $node = node_load($nid, TRUE);
-
-    // 1. Test that we can build an image tag from variables pre-rendered for an image field instance.
     $targeted_src = drupal_realpath($node->get('field_image', 0)->entity->uri);
     $expected_output = '<img class="layout-first-image" src="' . $targeted_src . '" />';
-    $this->assertRaw($expected_output, t('Node template was able to drill into field instance.  Node template was able to find first image field src as @src', array('@src' => $targeted_src)));
+    $this->assertRaw($expected_output, t('Twig template can access prepared variables for field instances.'));
   }
 
 }
diff --git a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
index ef5fb70..24749ca 100644
--- a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
+++ b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
@@ -29,4 +29,23 @@ public function phpVariablesRender() {
     return theme('twig_theme_test_php_variables');
   }
 
+  /**
+   * Menu callback for testing drillable elements in Twig templates.
+   */
+  public function drillableElementsRender() {
+    $links = array();
+    foreach (range(1, 5) as $i) {
+      $links[] = array(
+        '#type' => 'link',
+        '#title' => t('Link ' . $i),
+        '#href' => 'links/link-' . $i,
+        '#options' => array(),
+      );
+    }
+
+    return array(
+      '#theme' => 'twig_theme_test_drillable_elements',
+      '#links' => $links
+    );
+  }
 }
diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig-theme-test-drillable-elements.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig-theme-test-drillable-elements.html.twig
new file mode 100644
index 0000000..3647735
--- /dev/null
+++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig-theme-test-drillable-elements.html.twig
@@ -0,0 +1,8 @@
+{# Test overriding one of a set of links. #}
+{% for link in links %}
+  {% if loop.first %}
+    <a href="{{ link.attributes.href }}" {{ link.attributes }} cardinality="first">{{ link.title }}</a>
+  {% else %}
+    {{ link }}
+  {% endif %}
+{% endfor %}
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
index 2ca2cd0..435da1c 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
@@ -7,6 +7,12 @@ function twig_theme_test_theme($existing, $type, $theme, $path) {
   $items['twig_theme_test_php_variables'] = array(
     'template' => 'twig_theme_test.php_variables',
   );
+  $items['twig_theme_test_drillable_elements'] = array(
+    'template' => 'twig-theme-test-drillable-elements',
+    'variables' => array(
+      'links' => array(),
+    )
+  );
   return $items;
 }
 
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
index cdc0ac1..ee5dc94 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
@@ -4,3 +4,10 @@ twig_theme_test_php_variables:
     _content: '\Drupal\twig_theme_test\TwigThemeTestController::phpVariablesRender'
   requirements:
     _permission: 'access content'
+
+twig_theme_test_drillable_elements:
+  pattern: '/twig-theme-test/drillable-elements'
+  defaults:
+    _content: '\Drupal\twig_theme_test\TwigThemeTestController::drillableElementsRender'
+  requirements:
+    _permission: 'access content'
