Skip to content

Commit 1e7c60b

Browse files
committed
Renamed test mock MasterItem to ParentItem
1 parent 826dcde commit 1e7c60b

File tree

6 files changed

+69
-69
lines changed

6 files changed

+69
-69
lines changed

tests/Concerns/HasRelationsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Swis\JsonApi\Client\Relations\HasOneRelation;
1515
use Swis\JsonApi\Client\Relations\MorphToManyRelation;
1616
use Swis\JsonApi\Client\Relations\MorphToRelation;
17-
use Swis\JsonApi\Client\Tests\Mocks\Items\MasterItem;
17+
use Swis\JsonApi\Client\Tests\Mocks\Items\ParentItem;
1818
use Swis\JsonApi\Client\Util;
1919

2020
class HasRelationsTest extends TestCase
@@ -197,7 +197,7 @@ public function itCanDefineAHasOneRelation()
197197
/** @var \PHPUnit\Framework\MockObject\MockObject&\Swis\JsonApi\Client\Concerns\HasRelations $mock */
198198
$mock = $this->getMockForTrait(HasRelations::class);
199199

200-
$relation = $mock->hasOne(MasterItem::class, 'foo-bar');
200+
$relation = $mock->hasOne(ParentItem::class, 'foo-bar');
201201

202202
$this->assertInstanceOf(HasOneRelation::class, $relation);
203203
$this->assertSame($relation, $mock->getRelation('foo-bar'));
@@ -211,7 +211,7 @@ public function itCanDefineAHasOneRelationWithTheCallingMethodAsFallbackName()
211211
/** @var \PHPUnit\Framework\MockObject\MockObject&\Swis\JsonApi\Client\Concerns\HasRelations $mock */
212212
$mock = $this->getMockForTrait(HasRelations::class);
213213

214-
$relation = $mock->hasOne(MasterItem::class);
214+
$relation = $mock->hasOne(ParentItem::class);
215215

216216
$this->assertInstanceOf(HasOneRelation::class, $relation);
217217
$this->assertSame($relation, $mock->getRelation(Util::stringSnake(__FUNCTION__)));
@@ -225,7 +225,7 @@ public function itCanDefineAHasManyRelation()
225225
/** @var \PHPUnit\Framework\MockObject\MockObject&\Swis\JsonApi\Client\Concerns\HasRelations $mock */
226226
$mock = $this->getMockForTrait(HasRelations::class);
227227

228-
$relation = $mock->hasMany(MasterItem::class, 'foo-bar');
228+
$relation = $mock->hasMany(ParentItem::class, 'foo-bar');
229229

230230
$this->assertInstanceOf(HasManyRelation::class, $relation);
231231
$this->assertSame($relation, $mock->getRelation('foo-bar'));
@@ -239,7 +239,7 @@ public function itCanDefineAHasManyRelationWithTheCallingMethodAsFallbackName()
239239
/** @var \PHPUnit\Framework\MockObject\MockObject&\Swis\JsonApi\Client\Concerns\HasRelations $mock */
240240
$mock = $this->getMockForTrait(HasRelations::class);
241241

242-
$relation = $mock->hasMany(MasterItem::class);
242+
$relation = $mock->hasMany(ParentItem::class);
243243

244244
$this->assertInstanceOf(HasManyRelation::class, $relation);
245245
$this->assertSame($relation, $mock->getRelation(Util::stringSnake(__FUNCTION__)));

tests/ItemHydratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Swis\JsonApi\Client\Relations\MorphToManyRelation;
1515
use Swis\JsonApi\Client\Relations\MorphToRelation;
1616
use Swis\JsonApi\Client\Tests\Mocks\Items\AnotherRelatedItem;
17-
use Swis\JsonApi\Client\Tests\Mocks\Items\MasterItem;
17+
use Swis\JsonApi\Client\Tests\Mocks\Items\ParentItem;
1818
use Swis\JsonApi\Client\Tests\Mocks\Items\RelatedItem;
1919
use Swis\JsonApi\Client\Tests\Mocks\Items\WithRelationshipItem;
2020
use Swis\JsonApi\Client\TypeMapper;
@@ -589,10 +589,10 @@ public function itThrowsWhenRelationshipIsPresentInAvailableRelationshipsButTheM
589589
'does_not_exist' => '1',
590590
];
591591

592-
$item = new MasterItem();
592+
$item = new ParentItem();
593593

594594
$this->expectException(HydrationException::class);
595-
$this->expectExceptionMessage(sprintf('Method doesNotExist not found on %s', MasterItem::class));
595+
$this->expectExceptionMessage(sprintf('Method doesNotExist not found on %s', ParentItem::class));
596596

597597
$this->getItemHydrator()->hydrate($item, $data);
598598
}

tests/ItemTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Swis\JsonApi\Client\Links;
1414
use Swis\JsonApi\Client\Meta;
1515
use Swis\JsonApi\Client\Tests\Mocks\Items\ChildItem;
16-
use Swis\JsonApi\Client\Tests\Mocks\Items\MasterItem;
16+
use Swis\JsonApi\Client\Tests\Mocks\Items\ParentItem;
1717
use Swis\JsonApi\Client\Tests\Mocks\Items\RelatedItem;
1818
use Swis\JsonApi\Client\Tests\Mocks\Items\WithHiddenItem;
1919
use Swis\JsonApi\Client\Tests\Mocks\Items\WithRelationshipItem;
@@ -491,11 +491,11 @@ public function itIsNewWhenNoIdIsset()
491491
*/
492492
public function itCanGetARelationValueUsingGetAttributeMethod()
493493
{
494-
$masterItem = new MasterItem();
494+
$parentItem = new ParentItem();
495495
$childItem = new ChildItem();
496-
$masterItem->child()->associate($childItem);
496+
$parentItem->child()->associate($childItem);
497497

498-
$this->assertSame($childItem, $masterItem->getAttribute('child'));
498+
$this->assertSame($childItem, $parentItem->getAttribute('child'));
499499
}
500500

501501
/**
@@ -528,14 +528,14 @@ public function itReturnsABooleanIndicatingIfItHasAttributes()
528528
*/
529529
public function itCanGetAllRelationships()
530530
{
531-
$masterItem = new MasterItem();
531+
$parentItem = new ParentItem();
532532
$childItem = new ChildItem();
533533
$childItem->setId('1');
534534
$childItem->setMeta(new Meta(['foo' => 'bar']));
535-
$masterItem->child()->associate($childItem);
536-
$masterItem->children()->associate(new Collection([$childItem]));
535+
$parentItem->child()->associate($childItem);
536+
$parentItem->children()->associate(new Collection([$childItem]));
537537

538-
$relations = $masterItem->getRelationships();
538+
$relations = $parentItem->getRelationships();
539539

540540
$this->assertSame([
541541
'child' => [
@@ -566,13 +566,13 @@ public function itCanGetAllRelationships()
566566
*/
567567
public function itReturnsABooleanIndicatingIfItHasRelationships()
568568
{
569-
$masterItem = new MasterItem();
570-
$this->assertFalse($masterItem->hasRelationships());
569+
$parentItem = new ParentItem();
570+
$this->assertFalse($parentItem->hasRelationships());
571571

572572
$childItem = (new ChildItem())->setId('1');
573-
$masterItem->child()->associate($childItem);
573+
$parentItem->child()->associate($childItem);
574574

575-
$this->assertTrue($masterItem->hasRelationships());
575+
$this->assertTrue($parentItem->hasRelationships());
576576
}
577577

578578
/**

tests/Parsers/DocumentParserTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Swis\JsonApi\Client\Meta;
2020
use Swis\JsonApi\Client\Parsers\DocumentParser;
2121
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;
2323
use Swis\JsonApi\Client\TypeMapper;
2424

2525
class DocumentParserTest extends TestCase
@@ -201,7 +201,7 @@ public function itThrowsWhenItFindsDuplicateResources()
201201
[
202202
'data' => [
203203
[
204-
'type' => 'master',
204+
'type' => 'parent',
205205
'id' => '1',
206206
'attributes' => [
207207
'foo' => 'bar',
@@ -210,7 +210,7 @@ public function itThrowsWhenItFindsDuplicateResources()
210210
],
211211
'included' => [
212212
[
213-
'type' => 'master',
213+
'type' => 'parent',
214214
'id' => '1',
215215
'attributes' => [
216216
'foo' => 'bar',
@@ -232,7 +232,7 @@ public function itParsesAResourceDocument()
232232
json_encode(
233233
[
234234
'data' => [
235-
'type' => 'master',
235+
'type' => 'parent',
236236
'id' => '1',
237237
'attributes' => [
238238
'foo' => 'bar',
@@ -244,7 +244,7 @@ public function itParsesAResourceDocument()
244244

245245
$this->assertInstanceOf(ItemDocument::class, $document);
246246
$this->assertInstanceOf(ItemInterface::class, $document->getData());
247-
$this->assertEquals('master', $document->getData()->getType());
247+
$this->assertEquals('parent', $document->getData()->getType());
248248
$this->assertEquals('1', $document->getData()->getId());
249249
}
250250

@@ -259,7 +259,7 @@ public function itParsesAResourceCollectionDocument()
259259
[
260260
'data' => [
261261
[
262-
'type' => 'master',
262+
'type' => 'parent',
263263
'id' => '1',
264264
'attributes' => [
265265
'foo' => 'bar',
@@ -273,7 +273,7 @@ public function itParsesAResourceCollectionDocument()
273273
$this->assertInstanceOf(CollectionDocument::class, $document);
274274
$this->assertInstanceOf(Collection::class, $document->getData());
275275
$this->assertCount(1, $document->getData());
276-
$this->assertEquals('master', $document->getData()->get(0)->getType());
276+
$this->assertEquals('parent', $document->getData()->get(0)->getType());
277277
$this->assertEquals('1', $document->getData()->get(0)->getId());
278278
}
279279

@@ -308,7 +308,7 @@ public function itParsesIncluded()
308308
'data' => [],
309309
'included' => [
310310
[
311-
'type' => 'master',
311+
'type' => 'parent',
312312
'id' => '1',
313313
'attributes' => [
314314
'foo' => 'bar',
@@ -322,7 +322,7 @@ public function itParsesIncluded()
322322
$this->assertInstanceOf(CollectionDocument::class, $document);
323323
$this->assertInstanceOf(Collection::class, $document->getIncluded());
324324
$this->assertCount(1, $document->getIncluded());
325-
$this->assertEquals('master', $document->getIncluded()->get(0)->getType());
325+
$this->assertEquals('parent', $document->getIncluded()->get(0)->getType());
326326
$this->assertEquals('1', $document->getIncluded()->get(0)->getId());
327327
}
328328

@@ -332,15 +332,15 @@ public function itParsesIncluded()
332332
public function itLinksSingularRelationsToItemsFromIncluded()
333333
{
334334
$typeMapper = new TypeMapper();
335-
$typeMapper->setMapping('master', MasterItem::class);
335+
$typeMapper->setMapping('parent', ParentItem::class);
336336
$typeMapper->setMapping('child', ChildItem::class);
337337
$parser = DocumentParser::create($typeMapper);
338338

339339
$document = $parser->parse(
340340
json_encode(
341341
[
342342
'data' => [
343-
'type' => 'master',
343+
'type' => 'parent',
344344
'id' => '1',
345345
'attributes' => [
346346
'foo' => 'bar',
@@ -367,7 +367,7 @@ public function itLinksSingularRelationsToItemsFromIncluded()
367367
)
368368
);
369369

370-
$this->assertInstanceOf(MasterItem::class, $document->getData());
370+
$this->assertInstanceOf(ParentItem::class, $document->getData());
371371
$this->assertInstanceOf(ChildItem::class, $document->getData()->child()->getIncluded());
372372
$this->assertSame($document->getIncluded()->get(0), $document->getData()->child()->getIncluded());
373373
}
@@ -378,15 +378,15 @@ public function itLinksSingularRelationsToItemsFromIncluded()
378378
public function itDoesNotLinkEmptySingularRelations()
379379
{
380380
$typeMapper = new TypeMapper();
381-
$typeMapper->setMapping('master', MasterItem::class);
381+
$typeMapper->setMapping('parent', ParentItem::class);
382382
$typeMapper->setMapping('child', ChildItem::class);
383383
$parser = DocumentParser::create($typeMapper);
384384

385385
$document = $parser->parse(
386386
json_encode(
387387
[
388388
'data' => [
389-
'type' => 'master',
389+
'type' => 'parent',
390390
'id' => '1',
391391
'attributes' => [
392392
'foo' => 'bar',
@@ -410,7 +410,7 @@ public function itDoesNotLinkEmptySingularRelations()
410410
)
411411
);
412412

413-
$this->assertInstanceOf(MasterItem::class, $document->getData());
413+
$this->assertInstanceOf(ParentItem::class, $document->getData());
414414
$this->assertNull($document->getData()->child()->getIncluded());
415415
$this->assertInstanceOf(ChildItem::class, $document->getIncluded()->get(0));
416416
}
@@ -421,15 +421,15 @@ public function itDoesNotLinkEmptySingularRelations()
421421
public function itLinksPluralRelationsToItemsFromIncluded()
422422
{
423423
$typeMapper = new TypeMapper();
424-
$typeMapper->setMapping('master', MasterItem::class);
424+
$typeMapper->setMapping('parent', ParentItem::class);
425425
$typeMapper->setMapping('child', ChildItem::class);
426426
$parser = DocumentParser::create($typeMapper);
427427

428428
$document = $parser->parse(
429429
json_encode(
430430
[
431431
'data' => [
432-
'type' => 'master',
432+
'type' => 'parent',
433433
'id' => '1',
434434
'attributes' => [
435435
'foo' => 'bar',
@@ -469,7 +469,7 @@ public function itLinksPluralRelationsToItemsFromIncluded()
469469
)
470470
);
471471

472-
$this->assertInstanceOf(MasterItem::class, $document->getData());
472+
$this->assertInstanceOf(ParentItem::class, $document->getData());
473473
$this->assertInstanceOf(Collection::class, $document->getData()->children()->getIncluded());
474474
$this->assertInstanceOf(ChildItem::class, $document->getData()->children()->getIncluded()->get(0));
475475
$this->assertSame($document->getIncluded()->get(0), $document->getData()->children()->getIncluded()->get(0));
@@ -482,15 +482,15 @@ public function itLinksPluralRelationsToItemsFromIncluded()
482482
public function itDoesNotLinkEmptyPluralRelations()
483483
{
484484
$typeMapper = new TypeMapper();
485-
$typeMapper->setMapping('master', MasterItem::class);
485+
$typeMapper->setMapping('parent', ParentItem::class);
486486
$typeMapper->setMapping('child', ChildItem::class);
487487
$parser = DocumentParser::create($typeMapper);
488488

489489
$document = $parser->parse(
490490
json_encode(
491491
[
492492
'data' => [
493-
'type' => 'master',
493+
'type' => 'parent',
494494
'id' => '1',
495495
'attributes' => [
496496
'foo' => 'bar',
@@ -521,7 +521,7 @@ public function itDoesNotLinkEmptyPluralRelations()
521521
)
522522
);
523523

524-
$this->assertInstanceOf(MasterItem::class, $document->getData());
524+
$this->assertInstanceOf(ParentItem::class, $document->getData());
525525
$this->assertInstanceOf(Collection::class, $document->getData()->children()->getIncluded());
526526
$this->assertEmpty($document->getData()->children()->getIncluded());
527527
$this->assertInstanceOf(ChildItem::class, $document->getIncluded()->get(0));
@@ -605,15 +605,15 @@ public function itParsesMeta()
605605
public function itParsesMetaInRelationshipDataAndIncluded()
606606
{
607607
$typeMapper = new TypeMapper();
608-
$typeMapper->setMapping('master', MasterItem::class);
608+
$typeMapper->setMapping('parent', ParentItem::class);
609609
$typeMapper->setMapping('child', ChildItem::class);
610610
$parser = DocumentParser::create($typeMapper);
611611

612612
$document = $parser->parse(
613613
json_encode(
614614
[
615615
'data' => [
616-
'type' => 'master',
616+
'type' => 'parent',
617617
'id' => '1',
618618
'attributes' => [
619619
'foo' => 'bar',

0 commit comments

Comments
 (0)