Testing
This package also have some testing utilities built on top of PHPUnit and Laravel's framework assertions.
Assertions
$response = $this->getJson('/posts');
$response->assertJsonApi();at
use OpenSoutheners\LaravelApiable\Testing\AssertableJsonApi;
$response = $this->getJson('/posts');
$response->assertJsonApi(function (AssertableJsonApi $assert) {
$assert->at(0)->hasAttribute('title', 'Hello world');
});atRelation
use OpenSoutheners\LaravelApiable\Testing\AssertableJsonApi;
$response = $this->getJson('/posts');
$relatedComment = Comment::find(4);
$response->assertJsonApi(function (AssertableJsonApi $assert) use ($relatedComment) {
$assert->at(0)->atRelation($relatedComment)->hasAttribute('content', 'Foo bar');
});hasAttribute
hasNotAttribute
hasAttributes
hasNotAttributes
hasId
hasType
hasAnyRelationships
hasNotAnyRelationships
hasRelationshipWith
hasNotRelationshipWith
isCollection
isResource
Last updated