Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test for FormHelper::radio().

Tests generating radio input for field with model other than one used
in create(). Refs #2911.
  • Loading branch information...
commit a707709e1de2b0834942a87e7cdd88c90adcdb43 1 parent 0776b87
@ADmad ADmad authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
View
33 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -3731,6 +3731,39 @@ public function testRadio() {
}
/**
+ * testRadioDifferentModel
+ * Refs #2911
+ *
+ * @return void
+ */
+ public function testRadioDifferentModel() {
+ $this->Form->create('User');
+
+ $result = $this->Form->radio(
+ 'Model.field',
+ array('v1' => 'option A', 'v2' => 'option B'),
+ array('label' => true, 'legend' => false, 'value' => false)
+ );
+ $expected = array(
+ array('input' => array(
+ 'type' => 'radio', 'name' => 'data[Model][field]',
+ 'value' => 'v1', 'id' => 'ModelFieldV1'
+ )),
+ array('label' => array('for' => 'ModelFieldV1')),
+ 'option A',
+ '/label',
+ array('input' => array(
+ 'type' => 'radio', 'name' => 'data[Model][field]',
+ 'value' => 'v2', 'id' => 'ModelFieldV2'
+ )),
+ array('label' => array('for' => 'ModelFieldV2')),
+ 'option B',
+ '/label'
+ );
+ $this->assertTags($result, $expected);
+ }
+
+/**
* Test radio inputs with between as string or array. Also ensure
* that an array with less between elements works.
*
Please sign in to comment.
Something went wrong with that request. Please try again.