@@ -29,6 +29,37 @@ public function testAssertJsonContains(): void
2929 $ this ->assertJsonContains (['@context ' => '/contexts/Entrypoint ' ]);
3030 }
3131
32+ public function testAssertJsonContainsWithJsonObjectString (): void
33+ {
34+ if (version_compare (Version::id (), '8.0.0 ' , '< ' )) {
35+ $ this ->markTestSkipped ('Requires PHPUnit 8 ' );
36+ }
37+
38+ self ::createClient ()->request ('GET ' , '/ ' );
39+ $ this ->assertJsonContains (<<<JSON
40+ {
41+ "@context": "/contexts/Entrypoint"
42+ }
43+ JSON
44+ );
45+ }
46+
47+ public function testAssertJsonContainsWithJsonScalarString (): void
48+ {
49+ if (version_compare (Version::id (), '8.0.0 ' , '< ' )) {
50+ $ this ->markTestSkipped ('Requires PHPUnit 8 ' );
51+ }
52+
53+ $ this ->expectException (\InvalidArgumentException::class);
54+ $ this ->expectExceptionMessage ('$subset must be array or string (JSON array or JSON object) ' );
55+
56+ self ::createClient ()->request ('GET ' , '/ ' );
57+ $ this ->assertJsonContains (<<<JSON
58+ "/contexts/Entrypoint"
59+ JSON
60+ );
61+ }
62+
3263 public function testAssertJsonEquals (): void
3364 {
3465 self ::createClient ()->request ('GET ' , '/contexts/Address ' );
@@ -41,6 +72,33 @@ public function testAssertJsonEquals(): void
4172 ]);
4273 }
4374
75+ public function testAssertJsonEqualsWithJsonObjectString (): void
76+ {
77+ self ::createClient ()->request ('GET ' , '/contexts/Address ' );
78+ $ this ->assertJsonEquals (<<<JSON
79+ {
80+ "@context": {
81+ "@vocab": "http://example.com/docs.jsonld#",
82+ "hydra": "http://www.w3.org/ns/hydra/core#",
83+ "name": "Address/name"
84+ }
85+ }
86+ JSON
87+ );
88+ }
89+
90+ public function testAssertJsonEqualsWithJsonScalarString (): void
91+ {
92+ $ this ->expectException (\InvalidArgumentException::class);
93+ $ this ->expectExceptionMessage ('$json must be array or string (JSON array or JSON object) ' );
94+
95+ self ::createClient ()->request ('GET ' , '/contexts/Address ' );
96+ $ this ->assertJsonEquals (<<<JSON
97+ "Address/name"
98+ JSON
99+ );
100+ }
101+
44102 public function testAssertMatchesJsonSchema (): void
45103 {
46104 $ jsonSchema = <<<JSON
0 commit comments