File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
tests/Integration/Http/Resources/JsonApi Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,30 @@ public function testItCanGenerateJsonApiResponse()
8686 ->assertJsonMissing (['jsonapi ' , 'included ' ]);
8787 }
8888
89+ public function testItCanGenerateJsonApiResponseWithEmptyRelationship ()
90+ {
91+ $ user = UserFactory::new ()->create ();
92+
93+ $ this ->getJson ('/users/ ' .$ user ->getKey ().'? ' .http_build_query (['includes ' => ['posts ' ]]))
94+ ->assertHeader ('Content-type ' , 'application/vnd.api+json ' )
95+ ->assertExactJson ([
96+ 'data ' => [
97+ 'id ' => (string ) $ user ->getKey (),
98+ 'type ' => 'users ' ,
99+ 'attributes ' => [
100+ 'name ' => $ user ->name ,
101+ 'email ' => $ user ->email ,
102+ ],
103+ 'relationships ' => [
104+ 'posts ' => [
105+ 'data ' => [],
106+ ],
107+ ],
108+ ],
109+ ])
110+ ->assertJsonMissing (['jsonapi ' , 'included ' ]);
111+ }
112+
89113 public function testItCanGenerateJsonApiResponseWithEagerLoadedRelationship ()
90114 {
91115 $ user = UserFactory::new ()->create ();
You can’t perform that action at this time.
0 commit comments