Skip to content

Commit 0c30958

Browse files
committed
Add HasMany test
1 parent a755314 commit 0c30958

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Laravel/Tests/EloquentTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,17 @@ public function testBelongsTo(): void
447447
$this->assertEquals($json['sons'][0], '/api/grand_sons/1');
448448
}
449449

450+
public function testHasMany(): void
451+
{
452+
GrandSonFactory::new()->count(1)->create();
453+
454+
$res = $this->get('/api/grand_fathers/1/grand_sons', ['Accept' => ['application/ld+json']]);
455+
$json = $res->json();
456+
$this->assertEquals($json['@id'], '/api/grand_fathers/1/grand_sons');
457+
$this->assertEquals($json['totalItems'], 1);
458+
$this->assertEquals($json['member'][0]['@id'], '/api/grand_sons/1');
459+
}
460+
450461
public function testRelationIsHandledOnCreateWithNestedData(): void
451462
{
452463
$cartData = [

0 commit comments

Comments
 (0)