@@ -15,6 +15,15 @@ class DocumentLinkTest extends \PHPUnit_Framework_TestCase
1515 public function setUp ()
1616 {
1717 $ this ->manager = $ this ->buildManagerMock ();
18+
19+ // Mock parent
20+ $ this ->parent = $ this ->getMockBuilder ('Art4\JsonApiClient\AccessInterface ' )
21+ ->getMock ();
22+
23+ $ this ->parent ->expects ($ this ->any ())
24+ ->method ('has ' )
25+ ->with ('data ' )
26+ ->will ($ this ->returnValue (true ));
1827 }
1928
2029 /**
@@ -37,7 +46,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists()
3746 $ object ->custom = 'http://example.org/custom ' ;
3847 $ object ->meta = 'http://example.org/meta ' ;
3948
40- $ link = new DocumentLink ($ object , $ this ->manager );
49+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
4150
4251 $ this ->assertInstanceOf ('Art4\JsonApiClient\DocumentLink ' , $ link );
4352 $ this ->assertInstanceOf ('Art4\JsonApiClient\AccessInterface ' , $ link );
@@ -102,7 +111,7 @@ public function testCreateWithoutObjectThrowsException($input)
102111 'DocumentLink has to be an object, " ' . gettype ($ input ) . '" given. '
103112 );
104113
105- $ link = new DocumentLink ($ input , $ this ->manager );
114+ $ link = new DocumentLink ($ input , $ this ->manager , $ this -> parent );
106115 }
107116
108117 /**
@@ -126,7 +135,7 @@ public function testSelfMustBeAString($input)
126135 'property "self" has to be a string, " ' . gettype ($ input ) . '" given. '
127136 );
128137
129- $ link = new DocumentLink ($ object , $ this ->manager );
138+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
130139 }
131140
132141 /**
@@ -154,7 +163,7 @@ public function testRelatedMustBeAStringOrObject($input)
154163 // Input must be a string or object
155164 if ( gettype ($ input ) === 'string ' or gettype ($ input ) === 'object ' )
156165 {
157- $ link = new DocumentLink ($ object , $ this ->manager );
166+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
158167
159168 $ this ->assertTrue ($ link ->has ('related ' ));
160169
@@ -166,7 +175,7 @@ public function testRelatedMustBeAStringOrObject($input)
166175 'property "related" has to be a string or object, " ' . gettype ($ input ) . '" given. '
167176 );
168177
169- $ link = new DocumentLink ($ object , $ this ->manager );
178+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
170179 }
171180
172181 /**
@@ -183,7 +192,7 @@ public function testFirstCanBeAStringOrNull($input)
183192 // Input must be null or string
184193 if ( gettype ($ input ) === 'string ' )
185194 {
186- $ link = new DocumentLink ($ object , $ this ->manager );
195+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
187196 $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'first ' ));
188197
189198 $ this ->assertTrue ($ link ->has ('first ' ));
@@ -193,7 +202,7 @@ public function testFirstCanBeAStringOrNull($input)
193202 }
194203 elseif ( gettype ($ input ) === 'NULL ' )
195204 {
196- $ link = new DocumentLink ($ object , $ this ->manager );
205+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
197206 $ this ->assertSame ($ link ->getKeys (), array ('self ' ));
198207
199208 $ this ->assertFalse ($ link ->has ('first ' ));
@@ -206,7 +215,7 @@ public function testFirstCanBeAStringOrNull($input)
206215 'property "first" has to be a string or null, " ' . gettype ($ input ) . '" given. '
207216 );
208217
209- $ link = new DocumentLink ($ object , $ this ->manager );
218+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
210219 }
211220
212221 /**
@@ -223,7 +232,7 @@ public function testLastCanBeAStringOrNull($input)
223232 // Input must be null or string
224233 if ( gettype ($ input ) === 'string ' )
225234 {
226- $ link = new DocumentLink ($ object , $ this ->manager );
235+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
227236 $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'last ' ));
228237
229238 $ this ->assertTrue ($ link ->has ('last ' ));
@@ -233,7 +242,7 @@ public function testLastCanBeAStringOrNull($input)
233242 }
234243 elseif ( gettype ($ input ) === 'NULL ' )
235244 {
236- $ link = new DocumentLink ($ object , $ this ->manager );
245+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
237246 $ this ->assertSame ($ link ->getKeys (), array ('self ' ));
238247
239248 $ this ->assertFalse ($ link ->has ('last ' ));
@@ -246,7 +255,7 @@ public function testLastCanBeAStringOrNull($input)
246255 'property "last" has to be a string or null, " ' . gettype ($ input ) . '" given. '
247256 );
248257
249- $ link = new DocumentLink ($ object , $ this ->manager );
258+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
250259 }
251260
252261 /**
@@ -263,7 +272,7 @@ public function testPrevCanBeAStringOrNull($input)
263272 // Input must be null or string
264273 if ( gettype ($ input ) === 'string ' )
265274 {
266- $ link = new DocumentLink ($ object , $ this ->manager );
275+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
267276 $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'prev ' ));
268277
269278 $ this ->assertTrue ($ link ->has ('prev ' ));
@@ -273,7 +282,7 @@ public function testPrevCanBeAStringOrNull($input)
273282 }
274283 elseif ( gettype ($ input ) === 'NULL ' )
275284 {
276- $ link = new DocumentLink ($ object , $ this ->manager );
285+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
277286 $ this ->assertSame ($ link ->getKeys (), array ('self ' ));
278287
279288 $ this ->assertFalse ($ link ->has ('prev ' ));
@@ -286,7 +295,7 @@ public function testPrevCanBeAStringOrNull($input)
286295 'property "prev" has to be a string or null, " ' . gettype ($ input ) . '" given. '
287296 );
288297
289- $ link = new DocumentLink ($ object , $ this ->manager );
298+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
290299 }
291300
292301 /**
@@ -303,7 +312,7 @@ public function testNextCanBeAStringOrNull($input)
303312 // Input must be null or string
304313 if ( gettype ($ input ) === 'string ' )
305314 {
306- $ link = new DocumentLink ($ object , $ this ->manager );
315+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
307316 $ this ->assertSame ($ link ->getKeys (), array ('self ' , 'next ' ));
308317
309318 $ this ->assertTrue ($ link ->has ('next ' ));
@@ -313,7 +322,7 @@ public function testNextCanBeAStringOrNull($input)
313322 }
314323 elseif ( gettype ($ input ) === 'NULL ' )
315324 {
316- $ link = new DocumentLink ($ object , $ this ->manager );
325+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
317326 $ this ->assertSame ($ link ->getKeys (), array ('self ' ));
318327
319328 $ this ->assertFalse ($ link ->has ('next ' ));
@@ -326,7 +335,7 @@ public function testNextCanBeAStringOrNull($input)
326335 'property "next" has to be a string or null, " ' . gettype ($ input ) . '" given. '
327336 );
328337
329- $ link = new DocumentLink ($ object , $ this ->manager );
338+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
330339 }
331340
332341 /**
@@ -337,7 +346,7 @@ public function testGetOnANonExistingKeyThrowsException()
337346 $ object = new \stdClass ();
338347 $ object ->self = 'http://example.org/self ' ;
339348
340- $ link = new DocumentLink ($ object , $ this ->manager );
349+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
341350
342351 $ this ->assertFalse ($ link ->has ('something ' ));
343352
0 commit comments