File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rakit \Validation \Tests ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Rakit \Validation \Rules \Boolean ;
7+
8+ class BooleanTest extends TestCase
9+ {
10+ public function setUp ()
11+ {
12+ $ this ->rule = new Boolean ;
13+ }
14+
15+ public function testValids ()
16+ {
17+ $ this ->assertTrue ($ this ->rule ->check (\true));
18+ $ this ->assertTrue ($ this ->rule ->check (\false));
19+ $ this ->assertTrue ($ this ->rule ->check (1 ));
20+ $ this ->assertTrue ($ this ->rule ->check (0 ));
21+ $ this ->assertTrue ($ this ->rule ->check ('1 ' ));
22+ $ this ->assertTrue ($ this ->rule ->check ('0 ' ));
23+ $ this ->assertTrue ($ this ->rule ->check ('y ' ));
24+ $ this ->assertTrue ($ this ->rule ->check ('n ' ));
25+ }
26+
27+ public function testInvalids ()
28+ {
29+ $ this ->assertFalse ($ this ->rule ->check (11 ));
30+ $ this ->assertFalse ($ this ->rule ->check ([]));
31+ $ this ->assertFalse ($ this ->rule ->check ('foo123 ' ));
32+ $ this ->assertFalse ($ this ->rule ->check ('123foo ' ));
33+ $ this ->assertFalse ($ this ->rule ->check ([123 ]));
34+ $ this ->assertFalse ($ this ->rule ->check ('123.456 ' ));
35+ $ this ->assertFalse ($ this ->rule ->check ('-123.456 ' ));
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments