Browse Source

Split large test method

lilHermit 9 years ago
parent
commit
5482f3bc11
1 changed files with 51 additions and 39 deletions
  1. 51 39
      tests/TestCase/View/Helper/FormHelperTest.php

+ 51 - 39
tests/TestCase/View/Helper/FormHelperTest.php

@@ -8500,12 +8500,11 @@ class FormHelperTest extends TestCase
     /**
      * Tests to make sure `labelOptions` is rendered correctly by MultiCheckboxWidget and RadioWidget
      *
-     * Tests false, class (as string and array) also makes sure 'selected' is added to the class if checked.
-     * Also checks to make sure any custom attributes are rendered
+     * This test makes sure `false` excludes the label from the render
+     *
      */
-    public function testControlLabelManipulation()
+    public function testInputLabelManipulationDisableLabels()
     {
-        // Tests removal of label around input (Radio)
         $result = $this->Form->input('test', [
             'type' => 'radio',
             'options' => ['A', 'B'],
@@ -8523,7 +8522,43 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        // Tests String class (Radio)
+        $result = $this->Form->input('checkbox1', [
+            'label' => 'My checkboxes',
+            'multiple' => 'checkbox',
+            'type' => 'select',
+            'options' => [
+                ['text' => 'First Checkbox', 'value' => 1],
+                ['text' => 'Second Checkbox', 'value' => 2]
+            ],
+            'labelOptions' => false
+        ]);
+        $expected = [
+            ['div' => ['class' => 'input select']],
+            ['label' => ['for' => 'checkbox1']],
+            'My checkboxes',
+            '/label',
+            'input' => ['type' => 'hidden', 'name' => 'checkbox1', 'value' => ''],
+            ['div' => ['class' => 'checkbox']],
+            ['input' => ['type' => 'checkbox', 'name' => 'checkbox1[]', 'value' => '1', 'id' => 'checkbox1-1']],
+            '/div',
+            ['div' => ['class' => 'checkbox']],
+            ['input' => ['type' => 'checkbox', 'name' => 'checkbox1[]', 'value' => '2', 'id' => 'checkbox1-2']],
+            '/div',
+            '/div'
+        ];
+        $this->assertHtml($expected, $result);
+    }
+
+    /**
+     * Tests to make sure `labelOptions` is rendered correctly by RadioWidget
+     *
+     * This test checks rendering of class (as string and array) also makes sure 'selected' is
+     * added to the class if checked.
+     *
+     * Also checks to make sure any custom attributes are rendered correctly
+     */
+    public function testInputLabelManipulationRadios()
+    {
         $result = $this->Form->input('test', [
             'type' => 'radio',
             'options' => ['A', 'B'],
@@ -8547,7 +8582,6 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        // Tests to make sure selected is added to class (Radio)
         $result = $this->Form->input('test', [
             'type' => 'radio',
             'options' => ['A', 'B'],
@@ -8572,7 +8606,6 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        // Tests class as array and adding selected (Radio)
         $result = $this->Form->input('test', [
             'type' => 'radio',
             'options' => ['A', 'B'],
@@ -8597,7 +8630,6 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        // Tests class as array and adding selected as well as custom attributes (Radio)
         $result = $this->Form->radio('test', ['A', 'B'], [
             'label' => [
                 'class' => ['custom-class', 'another-class'],
@@ -8623,35 +8655,18 @@ class FormHelperTest extends TestCase
             '/label',
         ];
         $this->assertHtml($expected, $result);
+    }
 
-        // Tests removal of label around input (MultiCheckbox)
-        $result = $this->Form->input('checkbox1', [
-            'label' => 'My checkboxes',
-            'multiple' => 'checkbox',
-            'type' => 'select',
-            'options' => [
-                ['text' => 'First Checkbox', 'value' => 1],
-                ['text' => 'Second Checkbox', 'value' => 2]
-            ],
-            'labelOptions' => false
-        ]);
-        $expected = [
-            ['div' => ['class' => 'input select']],
-            ['label' => ['for' => 'checkbox1']],
-            'My checkboxes',
-            '/label',
-            'input' => ['type' => 'hidden', 'name' => 'checkbox1', 'value' => ''],
-            ['div' => ['class' => 'checkbox']],
-            ['input' => ['type' => 'checkbox', 'name' => 'checkbox1[]', 'value' => '1', 'id' => 'checkbox1-1']],
-            '/div',
-            ['div' => ['class' => 'checkbox']],
-            ['input' => ['type' => 'checkbox', 'name' => 'checkbox1[]', 'value' => '2', 'id' => 'checkbox1-2']],
-            '/div',
-            '/div'
-        ];
-        $this->assertHtml($expected, $result);
-
-        // Tests class as array, adding selected to class with custom attributes (MultiCheckbox)
+    /**
+     * Tests to make sure `labelOptions` is rendered correctly by MultiCheckboxWidget
+     *
+     * This test checks rendering of class (as string and array) also makes sure 'selected' is
+     * added to the class if checked.
+     *
+     * Also checks to make sure any custom attributes are rendered correctly
+     */
+    public function testInputLabelManipulationCheckboxes()
+    {
         $result = $this->Form->input('checkbox1', [
             'label' => 'My checkboxes',
             'multiple' => 'checkbox',
@@ -8663,7 +8678,6 @@ class FormHelperTest extends TestCase
             'labelOptions' => ['class' => 'custom-class'],
             'value' => ['1']
         ]);
-
         $expected = [
             ['div' => ['class' => 'input select']],
             ['label' => ['for' => 'checkbox1']],
@@ -8703,7 +8717,6 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        // Tests class as array, adding selected to class with custom attributes (MultiCheckbox)
         $result = $this->Form->input('checkbox1', [
             'label' => 'My checkboxes',
             'multiple' => 'checkbox',
@@ -8716,7 +8729,6 @@ class FormHelperTest extends TestCase
             'value' => ['1']
 
         ]);
-
         $expected = [
             ['div' => ['class' => 'input select']],
             ['label' => ['for' => 'checkbox1']],