@@ -144,10 +144,10 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input)
144144 *
145145 * self: the link that generated the current response document.
146146 */
147- public function testSelfMustBeAString ($ input )
147+ public function testSelfMustBeAStringOrObject ($ input )
148148 {
149149 // Input must be a string
150- if ( gettype ($ input ) === 'string ' )
150+ if ( gettype ($ input ) === 'string ' or gettype ( $ input ) === ' object ' )
151151 {
152152 return ;
153153 }
@@ -157,7 +157,7 @@ public function testSelfMustBeAString($input)
157157
158158 $ this ->setExpectedException (
159159 'Art4\JsonApiClient\Exception\ValidationException ' ,
160- 'property "self" has to be a string, " ' . gettype ($ input ) . '" given. '
160+ 'property "self" has to be a string or object , " ' . gettype ($ input ) . '" given. '
161161 );
162162
163163 $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
@@ -208,7 +208,7 @@ public function testRelatedMustBeAStringOrObject($input)
208208 *
209209 * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable.
210210 */
211- public function testFirstCanBeAStringOrNull ($ input )
211+ public function testFirstCanBeAnObjectOrStringOrNull ($ input )
212212 {
213213 $ object = new \stdClass ();
214214 $ object ->self = 'https://example.org/self ' ;
@@ -234,10 +234,20 @@ public function testFirstCanBeAStringOrNull($input)
234234
235235 return ;
236236 }
237+ elseif ( gettype ($ input ) === 'object ' )
238+ {
239+ $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
240+ $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'first ' ));
241+
242+ $ this ->assertTrue ($ link ->has ('first ' ));
243+ $ this ->assertInstanceOf ('Art4\JsonApiClient\LinkInterface ' , $ link ->get ('first ' ));
244+
245+ return ;
246+ }
237247
238248 $ this ->setExpectedException (
239249 'Art4\JsonApiClient\Exception\ValidationException ' ,
240- 'property "first" has to be a string or null, " ' . gettype ($ input ) . '" given. '
250+ 'property "first" has to be an object, a string or null, " ' . gettype ($ input ) . '" given. '
241251 );
242252
243253 $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
@@ -274,10 +284,20 @@ public function testLastCanBeAStringOrNull($input)
274284
275285 return ;
276286 }
287+ elseif ( gettype ($ input ) === 'object ' )
288+ {
289+ $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
290+ $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'last ' ));
291+
292+ $ this ->assertTrue ($ link ->has ('last ' ));
293+ $ this ->assertInstanceOf ('Art4\JsonApiClient\LinkInterface ' , $ link ->get ('last ' ));
294+
295+ return ;
296+ }
277297
278298 $ this ->setExpectedException (
279299 'Art4\JsonApiClient\Exception\ValidationException ' ,
280- 'property "last" has to be a string or null, " ' . gettype ($ input ) . '" given. '
300+ 'property "last" has to be an object, a string or null, " ' . gettype ($ input ) . '" given. '
281301 );
282302
283303 $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
@@ -314,10 +334,20 @@ public function testPrevCanBeAStringOrNull($input)
314334
315335 return ;
316336 }
337+ elseif ( gettype ($ input ) === 'object ' )
338+ {
339+ $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
340+ $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'prev ' ));
341+
342+ $ this ->assertTrue ($ link ->has ('prev ' ));
343+ $ this ->assertInstanceOf ('Art4\JsonApiClient\LinkInterface ' , $ link ->get ('prev ' ));
344+
345+ return ;
346+ }
317347
318348 $ this ->setExpectedException (
319349 'Art4\JsonApiClient\Exception\ValidationException ' ,
320- 'property "prev" has to be a string or null, " ' . gettype ($ input ) . '" given. '
350+ 'property "prev" has to be an object, a string or null, " ' . gettype ($ input ) . '" given. '
321351 );
322352
323353 $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
@@ -354,10 +384,20 @@ public function testNextCanBeAStringOrNull($input)
354384
355385 return ;
356386 }
387+ elseif ( gettype ($ input ) === 'object ' )
388+ {
389+ $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
390+ $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'next ' ));
391+
392+ $ this ->assertTrue ($ link ->has ('next ' ));
393+ $ this ->assertInstanceOf ('Art4\JsonApiClient\LinkInterface ' , $ link ->get ('next ' ));
394+
395+ return ;
396+ }
357397
358398 $ this ->setExpectedException (
359399 'Art4\JsonApiClient\Exception\ValidationException ' ,
360- 'property "next" has to be a string or null, " ' . gettype ($ input ) . '" given. '
400+ 'property "next" has to be an object, a string or null, " ' . gettype ($ input ) . '" given. '
361401 );
362402
363403 $ link = new DocumentLink ($ object , $ this ->manager , $ this ->parent );
0 commit comments