File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,11 @@ protected function parse($object)
60
60
$ links = get_object_vars ($ object );
61
61
62
62
if (array_key_exists ('self ' , $ links )) {
63
- if (! is_string ($ links ['self ' ])) {
64
- throw new ValidationException ('property "self" has to be a string, " ' . gettype ($ links ['self ' ]) . '" given. ' );
63
+ if (! is_string ($ links ['self ' ]) and ! is_object ( $ links [ ' self ' ]) ) {
64
+ throw new ValidationException ('property "self" has to be a string or object , " ' . gettype ($ links ['self ' ]) . '" given. ' );
65
65
}
66
66
67
- $ this ->set ('self ' , strval ( $ links ['self ' ]) );
67
+ $ this ->setLink ('self ' , $ links ['self ' ]);
68
68
69
69
unset($ links ['self ' ]);
70
70
}
Original file line number Diff line number Diff line change @@ -311,12 +311,12 @@ public function testCreateWithoutSelfAndRelatedPropertiesThrowsException()
311
311
*
312
312
* @param mixed $input
313
313
*/
314
- public function testSelfMustBeAString ($ input )
314
+ public function testSelfMustBeAStringOrObject ($ input )
315
315
{
316
316
$ link = new RelationshipLink ($ this ->manager , $ this ->relationship );
317
317
318
318
// Input must be a string
319
- if (gettype ($ input ) === 'string ' ) {
319
+ if (gettype ($ input ) === 'string ' or gettype ( $ input ) === ' object ' ) {
320
320
$ this ->assertInstanceOf ('Art4\JsonApiClient\RelationshipLink ' , $ link );
321
321
322
322
return ;
@@ -327,7 +327,7 @@ public function testSelfMustBeAString($input)
327
327
328
328
$ this ->setExpectedException (
329
329
'Art4\JsonApiClient\Exception\ValidationException ' ,
330
- 'property "self" has to be a string, " ' . gettype ($ input ) . '" given. '
330
+ 'property "self" has to be a string or object , " ' . gettype ($ input ) . '" given. '
331
331
);
332
332
333
333
$ link ->parse ($ object );
Original file line number Diff line number Diff line change @@ -264,20 +264,20 @@ public function testCreateWithoutSelfAndRelatedPropertiesThrowsException()
264
264
}
265
265
266
266
/**
267
- * @dataProvider jsonValuesProviderWithoutString
267
+ * @dataProvider jsonValuesProviderWithoutObjectAndString
268
268
*
269
269
* self: a link for the relationship itself (a "relationship link").
270
270
*
271
271
* @param mixed $input
272
272
*/
273
- public function testSelfMustBeAString ($ input )
273
+ public function testSelfMustBeAStringOrObject ($ input )
274
274
{
275
275
$ object = new \stdClass ();
276
276
$ object ->self = $ input ;
277
277
278
278
$ this ->expectException (ValidationException::class);
279
279
$ this ->expectExceptionMessage (
280
- 'property "self" has to be a string, " ' . gettype ($ input ) . '" given. '
280
+ 'property "self" has to be a string or object , " ' . gettype ($ input ) . '" given. '
281
281
);
282
282
283
283
$ link = new RelationshipLink ($ object , $ this ->manager , $ this ->relationship );
You can’t perform that action at this time.
0 commit comments