generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
CheckboxList
and RadioList
class for validate attri…
…butes. (#13)
- Loading branch information
1 parent
927bb64
commit efecac6
Showing
6 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace UIAwesome\Html\Tests\FormControl\Input\CheckboxList; | ||
|
||
use PHPForge\Support\Assert; | ||
use UIAwesome\Html\FormControl\Input\{Checkbox, CheckboxList}; | ||
|
||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class ValidateTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testRequired(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<label>Select your fruits?</label> | ||
<div> | ||
<input id="checkboxlist-w0" name="CheckboxForm[text][]" type="checkbox" value="2" required> | ||
<label for="checkboxlist-w0">Banana</label> | ||
<input id="checkboxlist-w1" name="CheckboxForm[text][]" type="checkbox" value="3" required> | ||
<label for="checkboxlist-w1">Orange</label> | ||
</div> | ||
HTML, | ||
CheckboxList::widget() | ||
->id('checkboxlist') | ||
->items( | ||
Checkbox::widget()->label('Banana')->value(2), | ||
Checkbox::widget()->label('Orange')->value(3), | ||
) | ||
->label('Select your fruits?') | ||
->name('CheckboxForm[text]') | ||
->required() | ||
->render(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace UIAwesome\Html\Tests\FormControl\Input\RadioList; | ||
|
||
use PHPForge\Support\Assert; | ||
use UIAwesome\Html\FormControl\Input\{Radio, RadioList}; | ||
|
||
final class ValidateTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testRequired(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<label>Select your gender?</label> | ||
<div> | ||
<input id="radiolist-w0" name="CheckboxForm[text]" type="radio" value="1" required> | ||
<label for="radiolist-w0">Female</label> | ||
<input id="radiolist-w1" name="CheckboxForm[text]" type="radio" value="2" required> | ||
<label class="value" for="radiolist-w1">Male</label> | ||
</div> | ||
HTML, | ||
RadioList::widget() | ||
->id('radiolist') | ||
->items( | ||
Radio::widget()->label('Female')->value(1), | ||
Radio::widget()->label('Male')->labelClass('value')->value(2), | ||
) | ||
->label('Select your gender?') | ||
->name('CheckboxForm[text]') | ||
->required() | ||
->render(), | ||
); | ||
} | ||
} |