Download the PHP package jcergolj/laravel-form-request-assertions without Composer

On this page you can find all versions of the php package jcergolj/laravel-form-request-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-form-request-assertions

Package for unit testing Laravel form request classes.

Why

Colin DeCarlo gave a talk on Laracon online 21 about unit testing Laravel form requests classes. If you haven't seen his talk, I recommend that you watch it. He prefers testing form requests as a unit and not as feature tests.I like this approach too.

He asked Freek Van der Herten to convert his gist code to package. Granted, I am not Freek; however, I accepted the challenge, and I did it myself. So this package is just a wrapper for Colin's gist, and I added two methods from Jason's package for asserting that controller has the form request.

Installation

Required PHP >=8.0

Usage

Controller

web.php routes

Request

Add the trait to a unit test

After package installation add the TestableFormRequest trait

Does the controller have the form request test?

or

Test failed Validation Rules

Test attribute has the rule

When dealing with more complicated rules, you might extract logic to dedicated custom rule class. In that instance you don't want to test the logic inside RequestTest class but rather in dedicated custom rule test class. Here you are only interested if the give attribute has/contains the custom rule.

Test assert subset of rules didn't fail

In some situations you might not care weather the whole request passed, but that only set of validation rules didn't fail.

ALERT this only checks that the rule didn't fail, it doesn't check that the rule was actually applied in the first place!

Test Form Request

Test data preparation

Test how data is prepared within the prepareForValidation method of the FormRequest.

Extending

If you need additional/custom assertions, you can easily extend the \Jcergolj\FormRequestAssertions\TestFormRequest class.

  1. Create a new class, for example: \Tests\Support\TestFormRequest extending the \Jcergolj\FormRequestAssertions\TestFormRequest class.

  2. Create a new trait, for example: \Tests\Traits\TestableFormRequest using the \Jcergolj\FormRequestAssertions\TestableFormRequest trait.
  3. Overwrite the \Jcergolj\FormRequestAssertions\TestableFormRequest::createNewTestFormRequest method to return an instance of the class created in (1).

  4. Use your custom trait instead of \Jcergolj\FormRequestAssertions\TestableFormRequest on your test classes

Available Methods

Contributors

A huge thanks go to Colin and Jason. I created a package from Colin's gist and I copied two methods from Jason's package.


Colin DeCarlo

Jason McCreary

Janez Cergolj

All versions of laravel-form-request-assertions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jcergolj/laravel-form-request-assertions contains the following files

Loading the files please wait ....