Skip to content

Commit

Permalink
$relation value is now an empty array instead of the '*' wildcard for…
Browse files Browse the repository at this point in the history
… security reasons.

Updated some misspelled names in TransformerTest.
  • Loading branch information
IlCallo committed Dec 5, 2017
1 parent 4e43a7d commit 5928b98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion resources/stubs/transformer.model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DummyClass extends Transformer
*
* @var string[]
*/
protected $relations = ['*'];
protected $relations = [];

/**
* List of autoloaded default relations.
Expand Down
2 changes: 1 addition & 1 deletion src/Transformers/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait HasRelationships
*
* @var string[]
*/
protected $relations = ['*'];
protected $relations = [];

/**
* A list of autoloaded default relations.
Expand Down
14 changes: 7 additions & 7 deletions tests/Unit/Transformers/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setUp()
*/
public function testGetAvailableIncludesMethodReturnsRelations()
{
$transformer = new TransformerWithoutWildard;
$transformer = new TransformerWithoutWildcard;

$includes = $transformer->getAvailableIncludes();

Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -145,27 +145,27 @@ 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 = []);

$this->assertEquals(['foo' => $childData], $result);
}
}

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
Expand Down

0 comments on commit 5928b98

Please sign in to comment.