From 5928b988303db39cba99088831ba8f0b09dac846 Mon Sep 17 00:00:00 2001 From: Paolo Caleffi Date: Tue, 5 Dec 2017 19:27:56 +0100 Subject: [PATCH] $relation value is now an empty array instead of the '*' wildcard for security reasons. Updated some misspelled names in TransformerTest. --- resources/stubs/transformer.model.stub | 2 +- src/Transformers/Concerns/HasRelationships.php | 2 +- tests/Unit/Transformers/TransformerTest.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/stubs/transformer.model.stub b/resources/stubs/transformer.model.stub index aeab3d9..546e910 100644 --- a/resources/stubs/transformer.model.stub +++ b/resources/stubs/transformer.model.stub @@ -12,7 +12,7 @@ class DummyClass extends Transformer * * @var string[] */ - protected $relations = ['*']; + protected $relations = []; /** * List of autoloaded default relations. diff --git a/src/Transformers/Concerns/HasRelationships.php b/src/Transformers/Concerns/HasRelationships.php index 95f75ce..d439498 100644 --- a/src/Transformers/Concerns/HasRelationships.php +++ b/src/Transformers/Concerns/HasRelationships.php @@ -21,7 +21,7 @@ trait HasRelationships * * @var string[] */ - protected $relations = ['*']; + protected $relations = []; /** * A list of autoloaded default relations. diff --git a/tests/Unit/Transformers/TransformerTest.php b/tests/Unit/Transformers/TransformerTest.php index 00b3d3f..6d833e1 100644 --- a/tests/Unit/Transformers/TransformerTest.php +++ b/tests/Unit/Transformers/TransformerTest.php @@ -44,7 +44,7 @@ public function setUp() */ public function testGetAvailableIncludesMethodReturnsRelations() { - $transformer = new TransformerWithoutWildard; + $transformer = new TransformerWithoutWildcard; $includes = $transformer->getAvailableIncludes(); @@ -56,7 +56,7 @@ public function testGetAvailableIncludesMethodReturnsRelations() */ public function testGetAvailableIncludesMethodReturnsResolvedRelationsOnWildcard() { - $transformer = new TransformerWithWildard; + $transformer = new TransformerWithWildcard; $transformer->setCurrentScope($scope = Mockery::mock(Scope::class)); $scope->shouldReceive('getParentScopes')->andReturn([]); $scope->shouldReceive('getManager')->andReturn($manager = Mockery::mock(Manager::class)); @@ -133,7 +133,7 @@ public function testProcessIncludedResourcesMethodMakesResourceImplicitlyWhenGiv */ public function testProcessIncludedResourcesMethodThrowsExceptionWhenNoRelationCanBeResolved() { - $transformer = new TransformerWithoutWildard; + $transformer = new TransformerWithoutWildcard; $transformer->setCurrentScope($scope = Mockery::mock(Scope::class)); $scope->shouldReceive('getParentScopes')->andReturn([]); $scope->shouldReceive('isRequested')->andReturn(true); @@ -145,7 +145,7 @@ public function testProcessIncludedResourcesMethodThrowsExceptionWhenNoRelationC $manager->shouldReceive('getRequestedIncludes')->andReturn([]); $manager->shouldReceive('getIncludeParams')->andReturn(new ParamBag([])); $this->expectException(LogicException::class); - $this->expectExceptionMessage('Relation [foo] not found in [' . TransformerWithoutWildard::class . '].'); + $this->expectExceptionMessage('Relation [foo] not found in [' . TransformerWithoutWildcard::class . '].'); $result = $transformer->processIncludedResources($scope, $data = []); @@ -153,19 +153,19 @@ public function testProcessIncludedResourcesMethodThrowsExceptionWhenNoRelationC } } -class TransformerWithoutWildard extends Transformer +class TransformerWithoutWildcard extends Transformer { protected $relations = ['foo', 'bar']; } -class TransformerWithWildard extends Transformer +class TransformerWithWildcard extends Transformer { protected $relations = ['*']; } class TransformerWithDefaultRelations extends Transformer { - protected $load = ['foo', 'bar' => TransformerWithoutWildard::class]; + protected $load = ['foo', 'bar' => TransformerWithoutWildcard::class]; } class TransformerWithRelationMethod extends Transformer