Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding tests for habtm data selection. Refs #256

  • Loading branch information...
commit b974127562049afdae405400c9fe11ad919477bb 1 parent 5f1d090
@markstory markstory authored
Showing with 49 additions and 0 deletions.
  1. +49 −0 cake/tests/cases/libs/view/helpers/form.test.php
View
49 cake/tests/cases/libs/view/helpers/form.test.php
@@ -3040,6 +3040,55 @@ function testSelectMultiple() {
}
/**
+ * 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
*
* @access public

0 comments on commit b974127

Please sign in to comment.
Something went wrong with that request. Please try again.