Browse Source

Add tests for templateVars & textarea widget.

Mark Story 10 years ago
parent
commit
2cedf1a1b2
1 changed files with 26 additions and 0 deletions
  1. 26 0
      tests/TestCase/View/Widget/TextareaWidgetTest.php

+ 26 - 0
tests/TestCase/View/Widget/TextareaWidgetTest.php

@@ -81,4 +81,30 @@ class TextareaWidgetTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
     }
+
+    /**
+     * Ensure templateVars option is hooked up.
+     *
+     * @return void
+     */
+    public function testRenderTemplateVars()
+    {
+        $this->templates->add([
+            'textarea' => '<textarea custom="{{custom}}" name="{{name}}"{{attrs}}>{{value}}</textarea>',
+        ]);
+
+        $input = new TextareaWidget($this->templates);
+        $data = [
+            'templateVars' => ['custom' => 'value'],
+            'name' => 'comment',
+            'val' => 'body'
+        ];
+        $result = $input->render($data, $this->context);
+        $expected = [
+            'textarea' => ['name' => 'comment', 'rows' => 5, 'custom' => 'value'],
+            'body',
+            '/textarea',
+        ];
+        $this->assertHtml($expected, $result);
+    }
 }