Skip to content

Commit 0ed469a

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent 1a51b54 commit 0ed469a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Integration/Http/Resources/JsonApi/JsonApiResourceTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)