@@ -174,6 +174,16 @@ public function testAssertJsonFragment()
174
174
$ response ->assertJsonFragment (['foobar ' => ['foobar_foo ' => 'foo ' , 'foobar_bar ' => 'bar ' ]]);
175
175
176
176
$ response ->assertJsonFragment (['foo ' => 'bar 0 ' , 'bar ' => ['foo ' => 'bar 0 ' , 'bar ' => 'foo 0 ' ]]);
177
+
178
+ $ response = TestResponse::fromBaseResponse (new Response (new JsonSerializableSingleResourceWithIntegersStub ()));
179
+
180
+ $ response ->assertJsonFragment (['id ' => 10 ]);
181
+
182
+ try {
183
+ $ response ->assertJsonFragment (['id ' => 1 ]);
184
+ $ this ->fail ('Asserting id => 1, existsing in JsonSerializableSingleResourceWithIntegersStub should fail ' );
185
+ } catch (\PHPUnit \Framework \ExpectationFailedException $ e ) {
186
+ }
177
187
}
178
188
179
189
public function testAssertJsonStructure ()
@@ -217,6 +227,13 @@ public function testAssertJsonCount()
217
227
$ response ->assertJsonCount (4 );
218
228
}
219
229
230
+ public function testAssertJsonMissing ()
231
+ {
232
+ $ response = TestResponse::fromBaseResponse (new Response (new JsonSerializableSingleResourceWithIntegersStub ));
233
+
234
+ $ response ->assertJsonMissing (['id ' => 2 ]);
235
+ }
236
+
220
237
public function testAssertJsonMissingValidationErrors ()
221
238
{
222
239
$ baseResponse = tap (new Response , function ($ response ) {
@@ -330,3 +347,15 @@ public function jsonSerialize()
330
347
];
331
348
}
332
349
}
350
+
351
+ class JsonSerializableSingleResourceWithIntegersStub implements JsonSerializable
352
+ {
353
+ public function jsonSerialize ()
354
+ {
355
+ return [
356
+ ['id ' => 10 , 'foo ' => 'bar ' ],
357
+ ['id ' => 20 , 'foo ' => 'bar ' ],
358
+ ['id ' => 30 , 'foo ' => 'bar ' ],
359
+ ];
360
+ }
361
+ }
0 commit comments