Browse Source

Add test case for FormHelper::checkbox().

ADmad 12 years ago
parent
commit
4e68d0532b
1 changed files with 40 additions and 0 deletions
  1. 40 0
      tests/TestCase/View/Helper/FormHelperTest.php

+ 40 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -4148,6 +4148,46 @@ class FormHelperTest extends TestCase {
 	}
 
 /**
+ * test generating radio input inside label ala twitter bootstrap
+ *
+ * @return void
+ */
+	public function testRadioInputInsideLabel() {
+		$this->Form->templates([
+			'label' => '<label{{attrs}}>{{input}}{{text}}</label>',
+			'radioContainer' => '{{label}}'
+		]);
+
+		$result = $this->Form->radio('Model.field', ['option A', 'option B']);
+		$expected = [
+			['input' => [
+				'type' => 'hidden',
+				'name' => 'Model[field]',
+				'value' => ''
+			]],
+			['label' => ['for' => 'model-field-0']],
+				['input' => [
+					'type' => 'radio',
+					'name' => 'Model[field]',
+					'value' => '0',
+					'id' => 'model-field-0'
+				]],
+				'option A',
+			'/label',
+			['label' => ['for' => 'model-field-1']],
+				['input' => [
+					'type' => 'radio',
+					'name' => 'Model[field]',
+					'value' => '1',
+					'id' => 'model-field-1'
+				]],
+				'option B',
+			'/label',
+		];
+		$this->assertTags($result, $expected);
+	}
+
+/**
  * test disabling the hidden input for radio buttons
  *
  * @return void