Skip to content

Commit

Permalink
Add tests for complex input rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 15, 2014
1 parent 9bf5c3e commit e8ed1f5
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/TestCase/View/Input/MultiCheckboxTest.php
Expand Up @@ -81,6 +81,50 @@ public function testRenderSimple() {
$this->assertTags($result, $expected);
}

/**
* 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.
*
Expand Down

0 comments on commit e8ed1f5

Please sign in to comment.