Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Test and coverage tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Coen Zimmerman committed May 27, 2017
1 parent c6ba0b8 commit d2e3699
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Support/Resource/AbstractEloquentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function relationshipData($include)
}

/**
* Returns the JSON-API type for a given include
* Returns the JSON-API type for a given include.
*
* @param string $include
* @return null|string
Expand All @@ -188,11 +188,9 @@ public function relationshipType($include)
$relation = $this->includeRelation($include);

if ($this->isVariableRelation($relation)) {

// @codeCoverageIgnoreStart
if ( ! $this->isSingularRelation($relation)) {
// @codeCoverageIgnoreStart
return null;
// @codeCoverageIgnoreEnd
}

// Get the type for the actually related item
Expand All @@ -204,6 +202,7 @@ public function relationshipType($include)
}

return $this->getTypeMaker()->makeFor(new $modelClass);
// @codeCoverageIgnoreEnd
}

return $this->getTypeMaker()->makeFor(
Expand Down
12 changes: 12 additions & 0 deletions tests/Support/Resource/EloquentResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ function it_returns_the_relation_method_instance_of_the_model_for_an_include_key
static::assertInstanceOf(HasMany::class, $resource->includeRelation('comments'));
}

/**
* @test
*/
function it_returns_the_relationship_type_for_a_given_include()
{
$resource = new TestAbstractEloquentResource;

$resource->setModel(new TestPost);

static::assertEquals('test-comments', $resource->relationshipType('comments'));
}

/**
* @test
*/
Expand Down

0 comments on commit d2e3699

Please sign in to comment.