vgirol / formrequest-tester
Tools to test Laravel FormRequest
Requires
- php: ^7.3|^8.0
- laravel/framework: ^6.0|^7.0|^8.0
Requires (Dev)
- infection/infection: ~0.14
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^9.0
- vgirol/phpunit-exception: dev-master
README
This package provides a set of tools to test Laravel FormRequest. It is strongly inspired by the package mohammedmanssour/form-request-tester.
Technologies
- PHP 7.3+
- Laravel 6+
Install
To install through composer, simply put the following in your composer.json
file:
{ "require-dev": { "vgirol/formrequest-tester": "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/formrequest-tester
Usage
Assertions can be chained :
use App\Requests\DummyFormRequest; use Orchestra\Testbench\TestCase; use VGirol\FormRequestTesterer\TestFormRequests; class FormRequestTester extends TestCase { use TestFormRequests; /** * @test */ public function myFirtsTest() { // Creates a form $form = [ 'data' => [ 'type' => 'dummy', 'attributes' => [ 'attr' => 'value' ] ] ]; // Create and validate form request for DummyFormRequest class $this->formRequest( DummyFormRequest::class, $form, [ 'method' => 'POST', 'route' => '/dummy-route' ] )->assertValidationPassed(); } }
Documentation
The API documentation is available in XHTML format at the url http://formrequest-tester.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.