Permalink
Browse files

Add tests for complex input rendering.

  • Loading branch information...
1 parent 9bf5c3e commit e8ed1f58f5e39d79182fda355da30cd35ca4e464 @markstory markstory committed Jan 15, 2014
Showing with 44 additions and 0 deletions.
  1. +44 −0 tests/TestCase/View/Input/MultiCheckboxTest.php
View
44 tests/TestCase/View/Input/MultiCheckboxTest.php
@@ -82,6 +82,50 @@ public function testRenderSimple() {
}
/**
+ * Test render complex and additional attributes.
+ *
+ * @return void
+ */
+ public function testRenderComplex() {
+ $input = new MultiCheckbox($this->templates);
+ $data = [
+ 'name' => 'Tags[id]',
+ 'options' => [
+ ['value' => '1', 'text' => 'CakePHP', 'data-test' => 'val'],
+ ['value' => '2', 'text' => 'Development', 'class' => 'custom'],
+ ]
+ ];
+ $result = $input->render($data);
+ $expected = [
+ ['div' => ['class' => 'checkbox']],
+ ['input' => [
+ 'type' => 'checkbox',
+ 'name' => 'Tags[id][]',
+ 'value' => 1,
+ 'id' => 'tags-id-1',
+ 'data-test' => 'val',
+ ]],
+ ['label' => ['for' => 'tags-id-1']],
+ 'CakePHP',
+ '/label',
+ '/div',
+ ['div' => ['class' => 'checkbox']],
+ ['input' => [
+ 'type' => 'checkbox',
+ 'name' => 'Tags[id][]',
+ 'value' => 2,
+ 'id' => 'tags-id-2',
+ 'class' => 'custom',
+ ]],
+ ['label' => ['for' => 'tags-id-2']],
+ 'Development',
+ '/label',
+ '/div',
+ ];
+ $this->assertTags($result, $expected);
+ }
+
+/**
* Test render escpaing options.
*
* @return void

0 comments on commit e8ed1f5

Please sign in to comment.