ソースを参照

Add test case for #8028

Mark Story 10 年 前
コミット
f2c84bca82

+ 26 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -583,6 +583,32 @@ class FormHelperTest extends TestCase
     }
 
     /**
+     * Test ensuring template variables work in template files loaded
+     * during input().
+     *
+     * @return void
+     */
+    public function testInputTemplatesFromFile()
+    {
+        $result = $this->Form->input('title', [
+            'templates' => 'test_templates',
+            'templateVars' => [
+                'forcontainer' => 'container-data'
+            ]
+        ]);
+        $expected = [
+            'div' => ['class'],
+            'label' => ['for'],
+            'Title',
+            '/label',
+            'input' => ['name', 'type' => 'text', 'id'],
+            'container-data',
+            '/div',
+        ];
+        $this->assertHtml($expected, $result);
+    }
+
+    /**
      * Test using template vars in inputSubmit and submitContainer template.
      *
      * @return void

+ 1 - 0
tests/test_app/config/test_templates.php

@@ -4,4 +4,5 @@
  */
 return [
     'link' => '<a href="{{url}}">{{text}}</a>',
+    'inputContainer' => '<div class="input {{type}}{{required}}">{{content}}{{forcontainer}}</div>'
 ];