Skip to content

Commit

Permalink
Adding test case for FormHelper::input() for generation multiple chec…
Browse files Browse the repository at this point in the history
…kboxes with space in option values. Refs #1465
  • Loading branch information
ADmad committed Jan 18, 2011
1 parent 932533c commit d4e4957
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -2173,6 +2173,35 @@ function testInputSelectType() {
'/div'
);
$this->assertTags($result, $expected);

$this->Form->data = array();
$result = $this->Form->input('Publisher.id', array(
'label' => 'Publisher',
'type' => 'select',
'multiple' => 'checkbox',
'options' => array('Value 1' => 'Label 1', 'Value 2' => 'Label 2')
));
$expected = array(
array('div' => array('class' => 'input select')),
array('label' => array('for' => 'PublisherId')),
'Publisher',
'/label',
'input' => array('type' => 'hidden', 'name' => 'data[Publisher][id]', 'value' => '', 'id' => 'PublisherId'),
array('div' => array('class' => 'checkbox')),
array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 1', 'id' => 'PublisherIdValue1')),
array('label' => array('for' => 'PublisherIdValue1')),
'Label 1',
'/label',
'/div',
array('div' => array('class' => 'checkbox')),
array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 2', 'id' => 'PublisherIdValue2')),
array('label' => array('for' => 'PublisherIdValue2')),
'Label 2',
'/label',
'/div',
'/div'
);
$this->assertTags($result, $expected);
}

/**
Expand Down Expand Up @@ -3132,7 +3161,7 @@ function testSelectOptionGroupEscaping() {
'/select'
);
$this->assertTags($result, $expected);

$options = array(
'>< Key' => array(
1 => 'One',
Expand Down Expand Up @@ -3510,7 +3539,7 @@ function testSelectMultipleCheckboxes() {
*/
function testSelectMultipleCheckboxDiv() {
$result = $this->Form->select(
'Model.tags',
'Model.tags',
array('first', 'second'),
null,
array('multiple' => 'checkbox', 'class' => 'my-class')
Expand Down Expand Up @@ -3539,7 +3568,7 @@ function testSelectMultipleCheckboxDiv() {

$result = $this->Form->input('Model.tags', array(
'options' => array('first', 'second'),
'multiple' => 'checkbox',
'multiple' => 'checkbox',
'class' => 'my-class',
'div' => false,
'label' => false
Expand Down Expand Up @@ -5743,7 +5772,7 @@ function testGetFormWithFalseModel() {
'accept-charset' => $encoding
));
$this->assertTags($result, $expected);

$result = $this->Form->text('reason');
$expected = array(
'input' => array('type' => 'text', 'name' => 'reason', 'id' => 'reason')
Expand Down

0 comments on commit d4e4957

Please sign in to comment.