Skip to content

Commit

Permalink
Adding tests for habtm data selection. Refs #256
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 4, 2009
1 parent 5f1d090 commit b974127
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -3039,6 +3039,55 @@ function testSelectMultiple() {
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }


/**
* test generation of habtm select boxes.
*
* @return void
**/
function testHabtmSelectBox() {
$view =& ClassRegistry::getObject('view');
$view->viewVars['contactTags'] = array(
1 => 'blue',
2 => 'red',
3 => 'green'
);
$this->Form->data = array(
'Contact' => array(),
'ContactTag' => array(
array(
'id' => 1,
'name' => 'blue'
),
array(
'id' => 3,
'name' => 'green'
)
)
);
$this->Form->create('Contact');
$result = $this->Form->input('ContactTag', array('div' => false, 'label' => false));
$expected = array(
'input' => array(
'type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => ''
),
'select' => array(
'name' => 'data[ContactTag][ContactTag][]', 'id' => 'ContactTagContactTag',
'multiple' => 'multiple'
),
array('option' => array('value' => '1', 'selected' => 'selected')),
'blue',
'/option',
array('option' => array('value' => '2')),
'red',
'/option',
array('option' => array('value' => '3', 'selected' => 'selected')),
'green',
'/option',
'/select'
);
$this->assertTags($result, $expected);
}

/** /**
* test generation of multi select elements in checkbox format * test generation of multi select elements in checkbox format
* *
Expand Down

0 comments on commit b974127

Please sign in to comment.