Skip to content

Commit

Permalink
Add unitTest_BcFreezeHelper_checkbox (baserproject#3573)
Browse files Browse the repository at this point in the history
Co-authored-by: thangnn <[email protected]>
  • Loading branch information
thangnnmd and thangnn authored Jul 8, 2024
1 parent f37df66 commit d509c9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/Helper/BcFreezeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public function wyear($fieldName, $minYear = null, $maxYear = null, $selected =
* @return string htmlタグ
* @checked
* @noTodo
* @unitTest
*/
public function checkbox(string $fieldName, array $options = []): array|string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,27 @@ public static function numberlDataProvider()
[true, 'baser.freezed', ['type' => 'hidden'], '<input type="hidden" name="baser[freezed]" value="123">123'],
];
}

/**
* @dataProvider checkboxProvider
*/
public function test_checkbox($freezed, $fieldName, $option, $expected)
{
if ($freezed) {
$this->BcFreeze->freeze();
}
$result = $this->BcFreeze->checkbox($fieldName, $option);
$this->assertEquals($expected, $result);
}


public static function checkboxProvider()
{
return [
[false, 'baser', ['label' => 'text'], '<input type="hidden" name="baser" value="0"><input type="checkbox" name="baser" value="1" label="text">'],
[true, 'baser', ['label' => 'text'], '<input type="hidden" name="baser" class="" ="" text="text">'],
[false, 'baser', [], '<input type="hidden" name="baser" value="0"><input type="checkbox" name="baser" value="1">'],
[true, 'baser', [], '<input type="hidden" name="baser" class="" ="" ="">'],
];
}
}

0 comments on commit d509c9a

Please sign in to comment.