File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class IsJsonTest extends TestCase
4+ {
5+ /** @test */
6+ public function it_returns_false_with_null_passed ()
7+ {
8+ $ this ->assertFalse (is_json (null ));
9+ }
10+
11+ /** @test */
12+ public function it_returns_false_with_boolean_true_passed ()
13+ {
14+ $ this ->assertFalse (is_json (true ));
15+ }
16+
17+ /** @test */
18+ public function it_returns_false_with_boolean_false_passed ()
19+ {
20+ $ this ->assertFalse (is_json (false ));
21+ }
22+
23+ /** @test */
24+ public function it_returns_false_with_integer_passed ()
25+ {
26+ $ this ->assertFalse (is_json (123 ));
27+ }
28+
29+ /** @test */
30+ public function it_returns_false_with_float_passed ()
31+ {
32+ $ this ->assertFalse (is_json (123.45 ));
33+ }
34+
35+ /** @test */
36+ public function it_returns_false_with_empty_array_passed ()
37+ {
38+ $ this ->assertFalse (is_json ([]));
39+ }
40+
41+ /** @test */
42+ public function it_returns_false_with_non_empty_array_passed ()
43+ {
44+ $ this ->assertFalse (is_json (['foo ' => 'bar ' ]));
45+ }
46+
47+ /** @test */
48+ public function it_returns_false_with_an_empty_string_passed ()
49+ {
50+ $ this ->assertFalse (is_json ('' ));
51+ }
52+
53+ /** @test */
54+ public function it_returns_false_with_non_json_string_passed ()
55+ {
56+ $ this ->assertFalse (is_json ('non-json string ' ));
57+ }
58+
59+ /** @test */
60+ public function it_returns_true_with_json_string_passed ()
61+ {
62+ $ json = json_encode (['foo ' => 'bar ' ]);
63+ $ this ->assertTrue (is_json ($ json ));
64+ }
65+ }
You can’t perform that action at this time.
0 commit comments