Skip to content

Commit

Permalink
SelectElementTest: use nowdoc for html content
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Nov 9, 2022
1 parent f94135d commit 5d6f095
Showing 1 changed file with 96 additions and 88 deletions.
184 changes: 96 additions & 88 deletions tests/FormElement/SelectElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ public function testFlatOptions()
],
]);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<option value="1">The one</option>'
. '<option value="4">Four</option>'
. '<option value="5">Hi five</option>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<option value="1">The one</option>
<option value="4">Four</option>
<option value="5">Hi five</option>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testOptionValidity()
Expand Down Expand Up @@ -104,19 +105,20 @@ public function testNestedOptions()
],
]);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<optgroup label="Some Options">'
. '<option value="1">The one</option>'
. '<option value="4">Four</option>'
. '</optgroup>'
. '<optgroup label="More options">'
. '<option value="5">Hi five</option>'
. '</optgroup>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<optgroup label="Some Options">
<option value="1">The one</option>
<option value="4">Four</option>
</optgroup>
<optgroup label="More options">
<option value="5">Hi five</option>
</optgroup>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testDisabledNestedOptions()
Expand All @@ -137,19 +139,20 @@ public function testDisabledNestedOptions()

$select->disableOptions([4, '5']);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<optgroup label="Some options">'
. '<option value="1">The one</option>'
. '<option value="4" disabled>Four</option>'
. '</optgroup>'
. '<optgroup label="More options">'
. '<option value="5" disabled>Hi five</option>'
. '</optgroup>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<optgroup label="Some options">
<option value="1">The one</option>
<option value="4" disabled>Four</option>
</optgroup>
<optgroup label="More options">
<option value="5" disabled>Hi five</option>
</optgroup>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testDeeplyDisabledNestedOptions()
Expand All @@ -174,23 +177,24 @@ public function testDeeplyDisabledNestedOptions()

$select->disableOptions([4, '5']);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<optgroup label="Some options">'
. '<option value="1">The one</option>'
. '<optgroup label="4">'
. '<optgroup label="Deeper">'
. '<option value="4x4">Fourfour</option>'
. '</optgroup>'
. '</optgroup>'
. '</optgroup>'
. '<optgroup label="More options">'
. '<option value="5" disabled>Hi five</option>'
. '</optgroup>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<optgroup label="Some options">
<option value="1">The one</option>
<optgroup label="4">
<optgroup label="Deeper">
<option value="4x4">Fourfour</option>
</optgroup>
</optgroup>
</optgroup>
<optgroup label="More options">
<option value="5" disabled>Hi five</option>
</optgroup>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testDefaultValueIsSelected()
Expand All @@ -206,15 +210,16 @@ public function testDefaultValueIsSelected()
]
]);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<option selected value="1">The one</option>'
. '<option value="4">Four</option>'
. '<option value="5">Hi five</option>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<option selected value="1">The one</option>
<option value="4">Four</option>
<option value="5">Hi five</option>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testSelectingMultipleOptions()
Expand Down Expand Up @@ -278,39 +283,42 @@ public function testSetValueSelectsAnOption()

$select->setValue('1');

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<option selected value="1">The one</option>'
. '<option value="4">Four</option>'
. '<option value="5">Hi five</option>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<option selected value="1">The one</option>
<option value="4">Four</option>
<option value="5">Hi five</option>
</select>
HTML;

$this->assertHtml($html, $select);

$select->setValue('5');

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<option value="1">The one</option>'
. '<option value="4">Four</option>'
. '<option selected value="5">Hi five</option>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<option value="1">The one</option>
<option value="4">Four</option>
<option selected value="5">Hi five</option>
</select>
HTML;

$this->assertHtml($html, $select);

$select->setValue(null);

$this->assertHtml(
'<select name="elname">'
. '<option value="">Please choose</option>'
. '<option value="1">The one</option>'
. '<option value="4">Four</option>'
. '<option value="5">Hi five</option>'
. '</select>',
$select
);
$html = <<<'HTML'
<select name="elname">
<option value="">Please choose</option>
<option value="1">The one</option>
<option value="4">Four</option>
<option value="5">Hi five</option>
</select>
HTML;

$this->assertHtml($html, $select);
}

public function testLabelCanBeChanged()
Expand Down

0 comments on commit 5d6f095

Please sign in to comment.