Skip to content

Commit 3f9647c

Browse files
committed
[Tests] Update sparse field sets test
See #135
1 parent bc228d3 commit 3f9647c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/dummy/tests/Api/V1/Posts/ReadTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,24 @@ public function testSparseFieldSets(): void
165165

166166
$expected = $this->serializer
167167
->post($post)
168-
->only('slug', 'synopsis', 'title')
168+
->only('author', 'slug', 'synopsis', 'title')
169+
->replace('author', ['type' => 'users', 'id' => $post->author])
170+
->jsonSerialize();
171+
172+
$author = $this->serializer
173+
->user($post->author)
174+
->only('name')
169175
->jsonSerialize();
170176

171177
$response = $this
172178
->withoutExceptionHandling()
173179
->jsonApi('posts')
174-
->sparseFields('posts', ['slug', 'synopsis', 'title'])
180+
->sparseFields('posts', ['author', 'slug', 'synopsis', 'title'])
181+
->sparseFields('users', ['name'])
182+
->includePaths('author')
175183
->get(url('/api/v1/posts', $expected['id']));
176184

177-
$response->assertFetchedOneExact($expected);
185+
$response->assertFetchedOneExact($expected)->assertIncluded([$author]);
178186
}
179187

180188
public function testWithCount(): void

0 commit comments

Comments
 (0)