mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding tests for habtm data selection. Refs #256
This commit is contained in:
parent
5f1d090bf0
commit
b974127562
1 changed files with 49 additions and 0 deletions
|
@ -3039,6 +3039,55 @@ class FormHelperTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue