PHPackages                             kishieel/laravel-form-request-unit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. kishieel/laravel-form-request-unit

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kishieel/laravel-form-request-unit
==================================

Laravel Form Request Unit Test Helper

1.1.2(4y ago)0117MITPHPPHP ^7.3|^8.0CI failing

Since Dec 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kishieel/laravel-form-request-unit)[ Packagist](https://packagist.org/packages/kishieel/laravel-form-request-unit)[ RSS](/packages/kishieel-laravel-form-request-unit/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

Laravel Form Request Unit
=========================

[](#laravel-form-request-unit)

[![Integration](https://github.com/kishieel/laravel-form-request-unit/actions/workflows/integration.yml/badge.svg)](https://github.com/kishieel/laravel-form-request-unit/actions/workflows/integration.yml)

Helpers for laravel form request unit testing. It allows you to keep your controller tests clean and focus on testing their proper purpose by taking form request assertions to separate tests.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require --dev kishieel/laravel-form-request-unit
```

Usage
-----

[](#usage)

### Rules Validation

[](#rules-validation)

With `FormRequestValidator` trait you may test your `FormRequest` without direct request to controller. Mentioned trait provide `validate` method which takes `FormRequest` and data which should be validated as arguments.

```
use Kishieel\RequestUnit\FormRequestValidator;

public function some_example_test()
{
    $formRequest = new YourFormRequest();
    $data = [
        'property_1' => 12,
        'property_2' => 'string'
    ];

    $result = $this->validate($formRequest, $data);
    // ..
}
```

As a result you will get `ValidatorResponse` which provide `passes` and `errors` methods. First method allow you to determinate whether data passes validation against form request rules. Second method may be used when you expected validation fail and want to determinate whether data failed against expected rule.

```
use Kishieel\RequestUnit\FormRequestValidator;

public function some_example_test()
{
    // ..

    $this->assertFalse($result->passes());
    $this->assertArrayHasKey('property_3', $result->errors());
}
```

### Selective Validation

[](#selective-validation)

With a very complex `FormRequest`, you may want to test data against only specified rules. You may achieve this by passing array of rule keys as third parameter of `validate` method.

```
use Kishieel\RequestUnit\FormRequestValidator;

public function some_example_test()
{
    // ..
    $result = $this->validate($formRequest, $data, ['property_1']);

    // will keep errors only for `property_1`
    $result->errors();
}
```

### Authorization Validation

[](#authorization-validation)

With `FormRequestValidator` you may validate `FormRequest` authorization method. Result will be available via `passes` method on validation result.

### Testing Custom Validation Rules

[](#testing-custom-validation-rules)

In case of custom validation rules you may use `FormRequestCreator` to create `FormRequest` on runtime and test it against your data. `FormRequestCreator` takes rules array and authorization callback as constructor arguments. Arguments are optional. You may use `setRules` and `setAuthorization` methods if you prefer.

```
Validator::extend('mac_address', function ($attribute, $value) {
    return preg_match('/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/', strval($value));
});
```

```
use Kishieel\RequestUnit\FormRequestValidator;

public function some_example_test()
{
    $formRequest = new \Kishieel\RequestUnit\FormRequestCreator([
        'mac_address' => 'required|mac_address'
    ]);

    $result = $this->validate($formRequest, ['mac_address' => 'invalid_mac_address']);

    $this->assertFalse($result->passes());
    $this->assertArrayHasKey('mac_address', $result->errors());
}
```

Contributing
------------

[](#contributing)

Before any pull request to `master` branch please run cs fixer and unit test.

```
composer fix
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

1616d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86ea21aa232db71b2ec45e8c5d0181f68a65c5b383db2f626df10fd6aca95c57?d=identicon)[kishieel](/maintainers/kishieel)

---

Top Contributors

[![kishieel](https://avatars.githubusercontent.com/u/49162745?v=4)](https://github.com/kishieel "kishieel (18 commits)")

---

Tags

testingphpunitlaravelform-requestkishieel

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/kishieel-laravel-form-request-unit/health.svg)

```
[![Health](https://phpackages.com/badges/kishieel-laravel-form-request-unit/health.svg)](https://phpackages.com/packages/kishieel-laravel-form-request-unit)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[sti3bas/laravel-scout-array-driver

Array driver for Laravel Scout

971.5M3](/packages/sti3bas-laravel-scout-array-driver)[srlabs/laravel-testing-utilities

Helper utilities for testing Laravel Applications

1011.9k](/packages/srlabs-laravel-testing-utilities)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
