@@ -15,6 +15,15 @@ class DocumentLinkTest extends \PHPUnit_Framework_TestCase
15
15
public function setUp ()
16
16
{
17
17
$ 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 ));
18
27
}
19
28
20
29
/**
@@ -37,7 +46,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists()
37
46
$ object ->custom = 'http://example.org/custom ' ;
38
47
$ object ->meta = 'http://example.org/meta ' ;
39
48
40
- $ link = new DocumentLink ($ object , $ this ->manager );
49
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
41
50
42
51
$ this ->assertInstanceOf ('Art4\JsonApiClient\DocumentLink ' , $ link );
43
52
$ this ->assertInstanceOf ('Art4\JsonApiClient\AccessInterface ' , $ link );
@@ -102,7 +111,7 @@ public function testCreateWithoutObjectThrowsException($input)
102
111
'DocumentLink has to be an object, " ' . gettype ($ input ) . '" given. '
103
112
);
104
113
105
- $ link = new DocumentLink ($ input , $ this ->manager );
114
+ $ link = new DocumentLink ($ input , $ this ->manager , $ this -> parent );
106
115
}
107
116
108
117
/**
@@ -126,7 +135,7 @@ public function testSelfMustBeAString($input)
126
135
'property "self" has to be a string, " ' . gettype ($ input ) . '" given. '
127
136
);
128
137
129
- $ link = new DocumentLink ($ object , $ this ->manager );
138
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
130
139
}
131
140
132
141
/**
@@ -154,7 +163,7 @@ public function testRelatedMustBeAStringOrObject($input)
154
163
// Input must be a string or object
155
164
if ( gettype ($ input ) === 'string ' or gettype ($ input ) === 'object ' )
156
165
{
157
- $ link = new DocumentLink ($ object , $ this ->manager );
166
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
158
167
159
168
$ this ->assertTrue ($ link ->has ('related ' ));
160
169
@@ -166,7 +175,7 @@ public function testRelatedMustBeAStringOrObject($input)
166
175
'property "related" has to be a string or object, " ' . gettype ($ input ) . '" given. '
167
176
);
168
177
169
- $ link = new DocumentLink ($ object , $ this ->manager );
178
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
170
179
}
171
180
172
181
/**
@@ -183,7 +192,7 @@ public function testFirstCanBeAStringOrNull($input)
183
192
// Input must be null or string
184
193
if ( gettype ($ input ) === 'string ' )
185
194
{
186
- $ link = new DocumentLink ($ object , $ this ->manager );
195
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
187
196
$ this ->assertSame ($ link ->getKeys (), array ('self ' , 'first ' ));
188
197
189
198
$ this ->assertTrue ($ link ->has ('first ' ));
@@ -193,7 +202,7 @@ public function testFirstCanBeAStringOrNull($input)
193
202
}
194
203
elseif ( gettype ($ input ) === 'NULL ' )
195
204
{
196
- $ link = new DocumentLink ($ object , $ this ->manager );
205
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
197
206
$ this ->assertSame ($ link ->getKeys (), array ('self ' ));
198
207
199
208
$ this ->assertFalse ($ link ->has ('first ' ));
@@ -206,7 +215,7 @@ public function testFirstCanBeAStringOrNull($input)
206
215
'property "first" has to be a string or null, " ' . gettype ($ input ) . '" given. '
207
216
);
208
217
209
- $ link = new DocumentLink ($ object , $ this ->manager );
218
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
210
219
}
211
220
212
221
/**
@@ -223,7 +232,7 @@ public function testLastCanBeAStringOrNull($input)
223
232
// Input must be null or string
224
233
if ( gettype ($ input ) === 'string ' )
225
234
{
226
- $ link = new DocumentLink ($ object , $ this ->manager );
235
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
227
236
$ this ->assertSame ($ link ->getKeys (), array ('self ' , 'last ' ));
228
237
229
238
$ this ->assertTrue ($ link ->has ('last ' ));
@@ -233,7 +242,7 @@ public function testLastCanBeAStringOrNull($input)
233
242
}
234
243
elseif ( gettype ($ input ) === 'NULL ' )
235
244
{
236
- $ link = new DocumentLink ($ object , $ this ->manager );
245
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
237
246
$ this ->assertSame ($ link ->getKeys (), array ('self ' ));
238
247
239
248
$ this ->assertFalse ($ link ->has ('last ' ));
@@ -246,7 +255,7 @@ public function testLastCanBeAStringOrNull($input)
246
255
'property "last" has to be a string or null, " ' . gettype ($ input ) . '" given. '
247
256
);
248
257
249
- $ link = new DocumentLink ($ object , $ this ->manager );
258
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
250
259
}
251
260
252
261
/**
@@ -263,7 +272,7 @@ public function testPrevCanBeAStringOrNull($input)
263
272
// Input must be null or string
264
273
if ( gettype ($ input ) === 'string ' )
265
274
{
266
- $ link = new DocumentLink ($ object , $ this ->manager );
275
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
267
276
$ this ->assertSame ($ link ->getKeys (), array ('self ' , 'prev ' ));
268
277
269
278
$ this ->assertTrue ($ link ->has ('prev ' ));
@@ -273,7 +282,7 @@ public function testPrevCanBeAStringOrNull($input)
273
282
}
274
283
elseif ( gettype ($ input ) === 'NULL ' )
275
284
{
276
- $ link = new DocumentLink ($ object , $ this ->manager );
285
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
277
286
$ this ->assertSame ($ link ->getKeys (), array ('self ' ));
278
287
279
288
$ this ->assertFalse ($ link ->has ('prev ' ));
@@ -286,7 +295,7 @@ public function testPrevCanBeAStringOrNull($input)
286
295
'property "prev" has to be a string or null, " ' . gettype ($ input ) . '" given. '
287
296
);
288
297
289
- $ link = new DocumentLink ($ object , $ this ->manager );
298
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
290
299
}
291
300
292
301
/**
@@ -303,7 +312,7 @@ public function testNextCanBeAStringOrNull($input)
303
312
// Input must be null or string
304
313
if ( gettype ($ input ) === 'string ' )
305
314
{
306
- $ link = new DocumentLink ($ object , $ this ->manager );
315
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
307
316
$ this ->assertSame ($ link ->getKeys (), array ('self ' , 'next ' ));
308
317
309
318
$ this ->assertTrue ($ link ->has ('next ' ));
@@ -313,7 +322,7 @@ public function testNextCanBeAStringOrNull($input)
313
322
}
314
323
elseif ( gettype ($ input ) === 'NULL ' )
315
324
{
316
- $ link = new DocumentLink ($ object , $ this ->manager );
325
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
317
326
$ this ->assertSame ($ link ->getKeys (), array ('self ' ));
318
327
319
328
$ this ->assertFalse ($ link ->has ('next ' ));
@@ -326,7 +335,7 @@ public function testNextCanBeAStringOrNull($input)
326
335
'property "next" has to be a string or null, " ' . gettype ($ input ) . '" given. '
327
336
);
328
337
329
- $ link = new DocumentLink ($ object , $ this ->manager );
338
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
330
339
}
331
340
332
341
/**
@@ -337,7 +346,7 @@ public function testGetOnANonExistingKeyThrowsException()
337
346
$ object = new \stdClass ();
338
347
$ object ->self = 'http://example.org/self ' ;
339
348
340
- $ link = new DocumentLink ($ object , $ this ->manager );
349
+ $ link = new DocumentLink ($ object , $ this ->manager , $ this -> parent );
341
350
342
351
$ this ->assertFalse ($ link ->has ('something ' ));
343
352
0 commit comments