Skip to content

Commit 2ca67dd

Browse files
authored
test it will call fields method when related request (#599)
* fix: test it will call fields method when related request * Fix styling --------- Co-authored-by: binaryk <[email protected]>
1 parent 1d41e72 commit 2ca67dd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Controllers/Index/IndexRelatedFeatureTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ public function it_can_paginate_keeping_relationships(): void
227227
->etc()
228228
);
229229
}
230+
231+
/** * @test */
232+
public function it_will_call_fields_method_for_related(): void
233+
{
234+
UserRepository::partialMock()
235+
->shouldReceive('fields')
236+
->once()
237+
->andReturn([
238+
field('name'),
239+
]);
240+
241+
PostRepository::$related = [
242+
'user' => BelongsTo::make('user', UserRepository::class),
243+
];
244+
245+
PostFactory::one();
246+
247+
$this->getJson(PostRepository::route(query: [
248+
'related' => 'user',
249+
]))->assertJson(
250+
fn (AssertableJson $json) => $json
251+
->has('data.0.relationships.user.attributes.name')
252+
->etc()
253+
);
254+
}
230255
}
231256

232257
class InvokableExtraMeta

0 commit comments

Comments
 (0)