Form Request Tester Package for Laravel

The Laravel Form Request Tester package is a collection of helpers that help test form requests. There are various ways to test form requests, either directly or through HTTP tests, that validate the behavior in form requests.

This package has helpers to scaffold a fake route if you want to isolate tests around your form request. You start by importing the provided testing trait TestsFormRequests:

use RenggaDev\FormRequestTester\TestsFormRequests;
class SomeTest extends TestCase
     use TestsFormRequests;
     // ...

The trait provides a formRequest method you can use to set up the form request and perform assertions on the form:

$form = $this->formRequest(UpdatePost::class)
    ->put(['title' => 'New Title']);
// Assertions
    ->assertValidationMessages(['Content field is required']);

There are some other assertion methods you can use to assert passing validation, authorization, and validation data:


You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Nandemo Webtools

Leave a Reply