Skip to content

Commit b8780a0

Browse files
committed
Add asserts for links and meta to HydratorTest
1 parent afc6f42 commit b8780a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/JsonApi/HydratorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,21 @@ protected function getJsonApiItemMock($type, $id)
9090
'type' => 'child',
9191
'id' => '2',
9292
],
93+
'links' => [
94+
'self' => 'http://example.com/'.$type.'/'.$id.'/relationships/child',
95+
],
96+
'meta' => [
97+
'foo' => 'bar',
98+
],
9399
],
94100
'morph' => [
95101
'data' => [
96102
'type' => 'child',
97103
'id' => '3',
98104
],
105+
'meta' => [
106+
'foo' => 'bar',
107+
],
99108
],
100109
'morphmany' => [
101110
'data' => [
@@ -112,6 +121,9 @@ protected function getJsonApiItemMock($type, $id)
112121
'id' => '6',
113122
],
114123
],
124+
'links' => [
125+
'self' => 'http://example.com/'.$type.'/'.$id.'/relationships/morphmany',
126+
],
115127
],
116128
],
117129
'links' => [
@@ -236,11 +248,15 @@ public function it_hydrates_relationships()
236248

237249
static::assertInstanceOf(MasterItem::class, $masterItem);
238250
static::assertInstanceOf(HasOneRelation::class, $masterItem->getRelationship('child'));
251+
static::assertInstanceOf(Links::class, $masterItem->getRelationship('child')->getLinks());
252+
static::assertInstanceOf(Meta::class, $masterItem->getRelationship('child')->getMeta());
239253

240254
static::assertSame($childItem, $masterItem->getRelationship('child')->getIncluded());
241255
static::assertEquals('child', $masterItem->getRelationship('child')->getIncluded()->getType());
242256
static::assertEquals(2, $masterItem->getRelationship('child')->getIncluded()->getId());
243257
static::assertSame($masterItem, $masterItem->getRelationship('child')->getIncluded()->getRelationship('parent')->getIncluded());
258+
static::assertSame('http://example.com/master/1/relationships/child', $masterItem->getRelationship('child')->getLinks()->self->getHref());
259+
static::assertSame('bar', $masterItem->getRelationship('child')->getMeta()->foo);
244260
}
245261

246262
/**

0 commit comments

Comments
 (0)