Skip to content

Commit

Permalink
Add additional tests for strict
Browse files Browse the repository at this point in the history
  • Loading branch information
adnandautovic committed Apr 7, 2022
1 parent e935943 commit 8f4a7b6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,14 @@ public function testCheckboxList()
<label><input type="checkbox" name="test[]" value="1.10"> 1.10</label></div>
EOD;
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', ['1.1'], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10'], ['strict' => true]));
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', [1.1], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10'], ['strict' => true]));

$expected = <<<'EOD'
<div><label><input type="checkbox" name="test[]" value="1"> 1</label>
<label><input type="checkbox" name="test[]" value="1.1" checked> 1.1</label>
<label><input type="checkbox" name="test[]" value="1.10" checked> 1.10</label></div>
EOD;
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', [1.1], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10']));
}

public function testRadioListWithArrayExpression()
Expand Down Expand Up @@ -923,6 +931,14 @@ public function testRadioList()
<label><input type="radio" name="test" value="1.10"> 1.10</label></div>
EOD;
$this->assertEqualsWithoutLE($expected, Html::radioList('test', ['1.1'], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10'], ['strict' => true]));
$this->assertEqualsWithoutLE($expected, Html::radioList('test', [1.1], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10'], ['strict' => true]));

$expected = <<<'EOD'
<div><label><input type="radio" name="test" value="1"> 1</label>
<label><input type="radio" name="test" value="1.1" checked> 1.1</label>
<label><input type="radio" name="test" value="1.10" checked> 1.10</label></div>
EOD;
$this->assertEqualsWithoutLE($expected, Html::radioList('test', ['1.1'], ['1' => '1', '1.1' => '1.1', '1.10' => '1.10']));
}

public function testUl()
Expand Down Expand Up @@ -1069,6 +1085,15 @@ public function testRenderOptions()
$data = ['1' => '1', '1.1' => '1.1', '1.10' => '1.10'];
$attributes = ['strict' => true];
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions(['1.1'], $data, $attributes));
$attributes = ['strict' => true];
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions([1.1], $data, $attributes));

$expected = <<<'EOD'
<option value="1">1</option>
<option value="1.1" selected>1.1</option>
<option value="1.10" selected>1.10</option>
EOD;
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions([1.1], $data));

$expected = <<<'EOD'
<option value="1">1</option>
Expand Down Expand Up @@ -1097,6 +1122,8 @@ public function testRenderOptions()
EOD;
$attributes = ['prompt' => 'Please select', 'strict' => true];
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions(false, $data, $attributes));
$attributes = ['prompt' => 'Please select', 'strict' => true];
$this->assertEqualsWithoutLE($expected, Html::renderSelectOptions([false], $data, $attributes));
}

public function testRenderTagAttributes()
Expand Down

0 comments on commit 8f4a7b6

Please sign in to comment.