@@ -36,6 +36,33 @@ public function testJsonApiWithEntityError()
3636 $ this ->assertEquals ($ this ->validationError , $ responseBody ->errors ->name ->_empty );
3737 }
3838
39+ public function testJsonApiWithEntitiesError ()
40+ {
41+ $ firstEntity = new Entity ();
42+ $ firstEntity ->setError ('name ' , ['_empty ' => $ this ->validationError ]);
43+ $ secondEntity = new Entity ();
44+ $ secondEntity ->setError ('name ' , ['_empty ' => $ this ->validationError ]);
45+ $ entities = [$ firstEntity , $ secondEntity ];
46+ $ exception = new JsonApiException ($ entities , $ this ->message );
47+
48+ $ request = (new ServerRequest ())
49+ ->withParam ('controller ' , 'Foo ' )
50+ ->withParam ('action ' , 'bar ' );
51+ $ exceptionRenderer = new JsonApiExceptionRenderer ($ exception , $ request );
52+
53+ $ response = $ exceptionRenderer ->render ();
54+
55+ $ this ->assertEquals (400 , $ response ->getStatusCode ());
56+ $ this ->assertEquals ('application/json ' , $ response ->getType ());
57+
58+ $ responseBody = json_decode ($ response ->__toString ());
59+ $ this ->assertEquals ($ this ->message , $ responseBody ->message );
60+ $ this ->assertEquals ('/ ' , $ responseBody ->url );
61+ $ this ->assertEquals (2 , $ responseBody ->errorCount );
62+ $ this ->assertEquals ($ this ->validationError , $ responseBody ->errors [0 ]->name ->_empty );
63+ $ this ->assertEquals ($ this ->validationError , $ responseBody ->errors [1 ]->name ->_empty );
64+ }
65+
3966 public function testJsonApiWithErrorCode ()
4067 {
4168 $ entity = new Entity ();
0 commit comments