File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ public function it_returns_false_with_non_empty_array_passed()
44
44
$ this ->assertFalse (is_json (['foo ' => 'bar ' ]));
45
45
}
46
46
47
+ /** @test */
48
+ public function it_returns_false_with_object_passed ()
49
+ {
50
+ $ this ->assertFalse (is_json (new StdClass ()));
51
+ }
52
+
47
53
/** @test */
48
54
public function it_returns_false_with_an_empty_string_passed ()
49
55
{
@@ -56,10 +62,24 @@ public function it_returns_false_with_non_json_string_passed()
56
62
$ this ->assertFalse (is_json ('non-json string ' ));
57
63
}
58
64
65
+ /** @test */
66
+ public function it_returns_false_with_non_json_string_and_second_argument_passed ()
67
+ {
68
+ $ this ->assertFalse (is_json ('non-json string ' , true ));
69
+ }
70
+
59
71
/** @test */
60
72
public function it_returns_true_with_json_string_passed ()
61
73
{
62
74
$ json = json_encode (['foo ' => 'bar ' ]);
63
75
$ this ->assertTrue (is_json ($ json ));
64
76
}
77
+
78
+ /** @test */
79
+ public function it_returns_decoded_json_with_second_argument_passed ()
80
+ {
81
+ $ array = ['foo ' => 'bar ' , 'baz ' => 'bax ' ];
82
+ $ json = json_encode ($ array );
83
+ $ this ->assertEquals ($ array , is_json ($ json , true ));
84
+ }
65
85
}
You can’t perform that action at this time.
0 commit comments