File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ public function withoutRelationships(): self
351
351
public function getRelations (): Collection
352
352
{
353
353
return $ this ->getRelationships ()->filter (function (array $ relation ) {
354
- return isset ( $ relation [ 'data ' ] );
354
+ return array_key_exists ( 'data ' , $ relation );
355
355
})->map (function (array $ relation ) {
356
356
return $ relation ['data ' ];
357
357
});
Original file line number Diff line number Diff line change @@ -122,6 +122,35 @@ public function testFields(): array
122
122
return $ expected ;
123
123
}
124
124
125
+ publi
EB0B
c function testFieldsWithEmptyToOne (): void
126
+ {
127
+ $ this ->values ['relationships ' ]['author ' ]['data ' ] = null ;
128
+
129
+ $ expected = [
130
+ 'author ' => null ,
131
+ 'content ' => '... ' ,
132
+ 'id ' => '1 ' ,
133
+ 'published ' => null ,
134
+ 'tags ' => [
135
+ [
136
+ 'type ' => 'tags ' ,
137
+ 'id ' => '4 ' ,
138
+ ],
139
+ [
140
+ 'type ' => 'tags ' ,
141
+ 'id ' => '5 ' ,
142
+ ],
143
+ ],
144
+ 'title ' => 'Hello World ' ,
145
+ 'type ' => 'posts ' ,
146
+ ];
147
+
148
+ $ resource = ResourceObject::create ($ this ->values );
149
+ $ this ->assertSame ($ expected , $ resource ->all ());
150
+ $ this ->assertNull ($ resource ['author ' ]);
151
+ $ this ->assertNull ($ resource ->get ('author ' , true ));
152
+ }
153
+
125
154
/**
126
155
* @param array $expected
127
156
* @depends testFields
You can’t perform that action at this time.
0 commit comments