Skip to content

Commit

Permalink
Update HtmlTest.php
Browse files Browse the repository at this point in the history
Pull Request Description
Changes:
Enhanced the selection check in Html::renderSelectOptions:
Added a condition to handle cases where $selection is an object that possesses a value property.
Rationale:
The primary goal of these changes is to provide improved flexibility in the types of data that can be passed as $selection and to streamline the comparison logic for better maintainability and clarity.

Test Additions:
Introduced a new test, to verify the behavior when $selection is an object with a value property.
  • Loading branch information
cristiangirlea authored Aug 17, 2023
1 parent 89600b2 commit 5112cde
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,21 @@ public function testRenderOptions()
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions(false, $data, $attributes));
$attributes = ['prompt' => 'Please select', 'strict' => true];
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions([false], $data, $attributes));

$data = [
'value1' => 'label1',
'value2' => 'label2',
];

$selectionObj = new \stdClass();
$selectionObj->value = 'value1';

$expected = <<<'EOD'
<option value="value1" selected>label1</option>
<option value="value2">label2</option>
EOD;

$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions($selectionObj, $data));
}

public function testRenderTagAttributes()
Expand Down

0 comments on commit 5112cde

Please sign in to comment.