@@ -29,6 +29,37 @@ public function testAssertJsonContains(): void
29
29
$ this ->assertJsonContains (['@context ' => '/contexts/Entrypoint ' ]);
30
30
}
31
31
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
+
32
63
public function testAssertJsonEquals (): void
33
64
{
34
65
self ::createClient ()->request ('GET ' , '/contexts/Address ' );
@@ -41,6 +72,33 @@ public function testAssertJsonEquals(): void
41
72
]);
42
73
}
43
74
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
+
44
102
public function testAssertMatchesJsonSchema (): void
45
103
{
46
104
$ jsonSchema = <<<JSON
0 commit comments