vgirol / jsonapi-assert-laravel
This package provides a set of assertions to test documents using Laravel and the JSON:API specification.
Requires
- php: ^7.3|^8.0
- laravel/framework: ^5.8|^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0
- vgirol/jsonapi-assert: dev-master
- vgirol/jsonapi-structure: dev-master
Requires (Dev)
- infection/infection: ~0.14
- orchestra/testbench: ~3.8|^4.0|^5.0|^6.0
- vgirol/jsonapi-faker: dev-master
- vgirol/jsonapi-faker-laravel: dev-master
- vgirol/phpunit-exception: dev-master
README
This package adds a lot of methods to the Illuminate\Testing\TestResponse
class for testing APIs that implements the JSON:API specification.
Table of content
Technologies
- PHP 7.3+
- PHPUnit 8.0+
- Laravel 7+
- JsonApi-Assert
Installation
To install through composer, simply put the following in your composer.json
file:
{ "require-dev": { "vgirol/jsonapi-assert-laravel": "dev-master" } }
And then run composer install
from the terminal.
Quick Installation
Above installation can also be simplified by using the following command:
composer require vgirol/jsonapi-assert-laravel
Registration
The package will automatically register itself. If you're not using Package Discovery, add the Service Provider to your config/app.php file:
VGirol\JsonApiAssert\Laravel\JsonApiAssertServiceProvider::class
Usage
/** * @test */ public function my_first_test() { // Sends request and gets response $response = $this->json('GET', 'endpoint'); // Checks the response (status code, headers) and the content $response->assertJsonApiResponse404( [ [ 'status' => '404', 'title' => 'Not Found' ] ] ); }
Documentation
The API documentation is available in XHTML format at the url http://jsonapi-assert-laravel.girol.fr/docs/ref/index.html.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email vincent@girol.fr instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.