Skip to content
Permalink
Browse files

Split large test method

  • Loading branch information...
lilHermit committed Feb 2, 2017
1 parent 2606865 commit 5482f3bc1190fc67ad212efc62cf97f87b88c4f3
Showing with 51 additions and 39 deletions.
  1. +51 −39 tests/TestCase/View/Helper/FormHelperTest.php
@@ -8500,12 +8500,11 @@ public function testNestedLabelInput()
/**
* 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 @@ public function testControlLabelManipulation()
];
$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 @@ public function testControlLabelManipulation()
];
$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 @@ public function testControlLabelManipulation()
];
$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 @@ public function testControlLabelManipulation()
];
$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 @@ public function testControlLabelManipulation()
'/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 @@ public function testControlLabelManipulation()
'labelOptions' => ['class' => 'custom-class'],
'value' => ['1']
]);
$expected = [
['div' => ['class' => 'input select']],
['label' => ['for' => 'checkbox1']],
@@ -8703,7 +8717,6 @@ public function testControlLabelManipulation()
];
$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 @@ public function testControlLabelManipulation()
'value' => ['1']
]);
$expected = [
['div' => ['class' => 'input select']],
['label' => ['for' => 'checkbox1']],

0 comments on commit 5482f3b

Please sign in to comment.
You can’t perform that action at this time.