19
19
use Swis \JsonApi \Client \Meta ;
20
20
use Swis \JsonApi \Client \Parsers \DocumentParser ;
21
21
use Swis \JsonApi \Client \Tests \Mocks \Items \ChildItem ;
22
- use Swis \JsonApi \Client \Tests \Mocks \Items \MasterItem ;
22
+ use Swis \JsonApi \Client \Tests \Mocks \Items \ParentItem ;
23
23
use Swis \JsonApi \Client \TypeMapper ;
24
24
25
25
class DocumentParserTest extends TestCase
@@ -201,7 +201,7 @@ public function itThrowsWhenItFindsDuplicateResources()
201
201
[
202
202
'data ' => [
203
203
[
204
- 'type ' => 'master ' ,
204
+ 'type ' => 'parent ' ,
205
205
'id ' => '1 ' ,
206
206
'attributes ' => [
207
207
'foo ' => 'bar ' ,
@@ -210,7 +210,7 @@ public function itThrowsWhenItFindsDuplicateResources()
210
210
],
211
211
'included ' => [
212
212
[
213
- 'type ' => 'master ' ,
213
+ 'type ' => 'parent ' ,
214
214
'id ' => '1 ' ,
215
215
'attributes ' => [
216
216
'foo ' => 'bar ' ,
@@ -232,7 +232,7 @@ public function itParsesAResourceDocument()
232
232
json_encode (
233
233
[
234
234
'data ' => [
235
- 'type ' => 'master ' ,
235
+ 'type ' => 'parent ' ,
236
236
'id ' => '1 ' ,
237
237
'attributes ' => [
238
238
'foo ' => 'bar ' ,
@@ -244,7 +244,7 @@ public function itParsesAResourceDocument()
244
244
245
245
$ this ->assertInstanceOf (ItemDocument::class, $ document );
246
246
$ this ->assertInstanceOf (ItemInterface::class, $ document ->getData ());
247
- $ this ->assertEquals ('master ' , $ document ->getData ()->getType ());
247
+ $ this ->assertEquals ('parent ' , $ document ->getData ()->getType ());
248
248
$ this ->assertEquals ('1 ' , $ document ->getData ()->getId ());
249
249
}
250
250
@@ -259,7 +259,7 @@ public function itParsesAResourceCollectionDocument()
259
259
[
260
260
'data ' => [
261
261
[
262
- 'type ' => 'master ' ,
262
+ 'type ' => 'parent ' ,
263
263
'id ' => '1 ' ,
264
264
'attributes ' => [
265
265
'foo ' => 'bar ' ,
@@ -273,7 +273,7 @@ public function itParsesAResourceCollectionDocument()
273
273
$ this ->assertInstanceOf (CollectionDocument::class, $ document );
274
274
$ this ->assertInstanceOf (Collection::class, $ document ->getData ());
275
275
$ this ->assertCount (1 , $ document ->getData ());
276
- $ this ->assertEquals ('master ' , $ document ->getData ()->get (0 )->getType ());
276
+ $ this ->assertEquals ('parent ' , $ document ->getData ()->get (0 )->getType ());
277
277
$ this ->assertEquals ('1 ' , $ document ->getData ()->get (0 )->getId ());
278
278
}
279
279
@@ -308,7 +308,7 @@ public function itParsesIncluded()
308
308
'data ' => [],
309
309
'included ' => [
310
310
[
311
- 'type ' => 'master ' ,
311
+ 'type ' => 'parent ' ,
312
312
'id ' => '1 ' ,
313
313
'attributes ' => [
314
314
'foo ' => 'bar ' ,
@@ -322,7 +322,7 @@ public function itParsesIncluded()
322
322
$ this ->assertInstanceOf (CollectionDocument::class, $ document );
323
323
$ this ->assertInstanceOf (Collection::class, $ document ->getIncluded ());
324
324
$ this ->assertCount (1 , $ document ->getIncluded ());
325
- $ this ->assertEquals ('master ' , $ document ->getIncluded ()->get (0 )->getType ());
325
+ $ this ->assertEquals ('parent ' , $ document ->getIncluded ()->get (0 )->getType ());
326
326
$ this ->assertEquals ('1 ' , $ document ->getIncluded ()->get (0 )->getId ());
327
327
}
328
328
@@ -332,15 +332,15 @@ public function itParsesIncluded()
332
332
public function itLinksSingularRelationsToItemsFromIncluded ()
333
333
{
334
334
$ typeMapper = new TypeMapper ();
335
- $ typeMapper ->setMapping ('master ' , MasterItem ::class);
335
+ $ typeMapper ->setMapping ('parent ' , ParentItem ::class);
336
336
$ typeMapper ->setMapping ('child ' , ChildItem::class);
337
337
$ parser = DocumentParser::create ($ typeMapper );
338
338
339
339
$ document = $ parser ->parse (
340
340
json_encode (
341
341
[
342
342
'data ' => [
343
- 'type ' => 'master ' ,
343
+ 'type ' => 'parent ' ,
344
344
'id ' => '1 ' ,
345
345
'attributes ' => [
346
346
'foo ' => 'bar ' ,
@@ -367,7 +367,7 @@ public function itLinksSingularRelationsToItemsFromIncluded()
367
367
)
368
368
);
369
369
370
- $ this ->assertInstanceOf (MasterItem ::class, $ document ->getData ());
370
+ $ this ->assertInstanceOf (ParentItem ::class, $ document ->getData ());
371
371
$ this ->assertInstanceOf (ChildItem::class, $ document ->getData ()->child ()->getIncluded ());
372
372
$ this ->assertSame ($ document ->getIncluded ()->get (0 ), $ document ->getData ()->child ()->getIncluded ());
373
373
}
@@ -378,15 +378,15 @@ public function itLinksSingularRelationsToItemsFromIncluded()
378
378
public function itDoesNotLinkEmptySingularRelations ()
379
379
{
380
380
$ typeMapper = new TypeMapper ();
381
- $ typeMapper ->setMapping ('master ' , MasterItem ::class);
381
+ $ typeMapper ->setMapping ('parent ' , ParentItem ::class);
382
382
$ typeMapper ->setMapping ('child ' , ChildItem::class);
383
383
$ parser = DocumentParser::create ($ typeMapper );
384
384
385
385
$ document = $ parser ->parse (
386
386
json_encode (
387
387
[
388
388
'data ' => [
389
- 'type ' => 'master ' ,
389
+ 'type ' => 'parent ' ,
390
390
'id ' => '1 ' ,
391
391
'attributes ' => [
392
392
'foo ' => 'bar ' ,
@@ -410,7 +410,7 @@ public function itDoesNotLinkEmptySingularRelations()
410
410
)
411
411
);
412
412
413
- $ this ->assertInstanceOf (MasterItem ::class, $ document ->getData ());
413
+ $ this ->assertInstanceOf (ParentItem ::class, $ document ->getData ());
414
414
$ this ->assertNull ($ document ->getData ()->child ()->getIncluded ());
415
415
$ this ->assertInstanceOf (ChildItem::class, $ document ->getIncluded ()->get (0 ));
416
416
}
@@ -421,15 +421,15 @@ public function itDoesNotLinkEmptySingularRelations()
421
421
public function itLinksPluralRelationsToItemsFromIncluded ()
422
422
{
423
423
$ typeMapper = new TypeMapper ();
424
- $ typeMapper ->setMapping ('master ' , MasterItem ::class);
424
+ $ typeMapper ->setMapping ('parent ' , ParentItem ::class);
425
425
$ typeMapper ->setMapping ('child ' , ChildItem::class);
426
426
$ parser = DocumentParser::create ($ typeMapper );
427
427
428
428
$ document = $ parser ->parse (
429
429
json_encode (
430
430
[
431
431
'data ' => [
432
- 'type ' => 'master ' ,
432
+ 'type ' => 'parent ' ,
433
433
'id ' => '1 ' ,
434
434
'attributes ' => [
435
435
'foo ' => 'bar ' ,
@@ -469,7 +469,7 @@ public function itLinksPluralRelationsToItemsFromIncluded()
469
469
)
470
470
);
471
471
472
- $ this ->assertInstanceOf (MasterItem ::class, $ document ->getData ());
472
+ $ this ->assertInstanceOf (ParentItem ::class, $ document ->getData ());
473
473
$ this ->assertInstanceOf (Collection::class, $ document ->getData ()->children ()->getIncluded ());
474
474
$ this ->assertInstanceOf (ChildItem::class, $ document ->getData ()->children ()->getIncluded ()->get (0 ));
475
475
$ this ->assertSame ($ document ->getIncluded ()->get (0 ), $ document ->getData ()->children ()->getIncluded ()->get (0 ));
@@ -482,15 +482,15 @@ public function itLinksPluralRelationsToItemsFromIncluded()
482
482
public function itDoesNotLinkEmptyPluralRelations ()
483
483
{
484
484
$ typeMapper = new TypeMapper ();
485
- $ typeMapper ->setMapping ('master ' , MasterItem ::class);
485
+ $ typeMapper ->setMapping ('parent ' , ParentItem ::class);
486
486
$ typeMapper ->setMapping ('child ' , ChildItem::class);
487
487
$ parser = DocumentParser::create ($ typeMapper );
488
488
489
489
$ document = $ parser ->parse (
490
490
json_encode (
491
491
[
492
492
'data ' => [
493
- 'type ' => 'master ' ,
493
+ 'type ' => 'parent ' ,
494
494
'id ' => '1 ' ,
495
495
'attributes ' => [
496
496
'foo ' => 'bar ' ,
@@ -521,7 +521,7 @@ public function itDoesNotLinkEmptyPluralRelations()
521
521
)
522
522
);
523
523
524
- $ this ->assertInstanceOf (MasterItem ::class, $ document ->getData ());
524
+ $ this ->assertInstanceOf (ParentItem ::class, $ document ->getData ());
525
525
$ this ->assertInstanceOf (Collection::class, $ document ->getData ()->children ()->getIncluded ());
526
526
$ this ->assertEmpty ($ document ->getData ()->children ()->getIncluded ());
527
527
$ this ->assertInstanceOf (ChildItem::class, $ document ->getIncluded ()->get (0 ));
@@ -605,15 +605,15 @@ public function itParsesMeta()
605
605
public function itParsesMetaInRelationshipDataAndIncluded ()
606
606
{
607
607
$ typeMapper = new TypeMapper ();
608
- $ typeMapper ->setMapping ('master ' , MasterItem ::class);
608
+ $ typeMapper ->setMapping ('parent ' , ParentItem ::class);
609
609
$ typeMapper ->setMapping ('child ' , ChildItem::class);
610
610
$ parser = DocumentParser::create ($ typeMapper );
611
611
612
612
$ document = $ parser ->parse (
613
613
json_encode (
614
614
[
615
615
'data ' => [
616
- 'type ' => 'master ' ,
616
+ 'type ' => 'parent ' ,
617
617
'id ' => '1 ' ,
618
618
'attributes ' => [
619
619
'foo ' => 'bar ' ,
0 commit comments