Download the PHP package mohammedmanssour/form-request-tester without Composer

On this page you can find all versions of the php package mohammedmanssour/form-request-tester. 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 form-request-tester

Laravel FormRequest Tester

A Simple collection of test helpers that help testing form request the easy way.

Why Bother

for full story on why this package was built please refer to This Blog Post

Installation

  1. Using composer

  2. add MohammedManssour\FormRequestTester\TestsFormRequests trait to your test case.

Testing a form request

  1. you need to intialize the form request using formRequest method, it takes the FormRequest class as first argument and an array of request data as a second argument

or you can use the intuitive methods to set form request method and data

the previous code will intialize the request with post method and /fake-route if you want to change these options you can via the options array that can be set as a third argument

  1. use the available assertions to test for request

Available Assertions

$this->assertValidationPassed() To make sure the validation have passed successfully with the help of the provided data.
$this->assertValidationFailed() To make sure the validation have failed with the help of the provided data.
$this->assertValidationErrors($keysArray) To assert that the keys mentioned in the $keysArray have occurred in the errors bag.
$this->assertValidationErrorsMissing($keysArray) To assert that the keys mentioned in the $keysArray have not occurred in the errors bag.
$this->assertValidationMessages($messagesArray) To assert that the messages exists in the error bag. Used when you define custom messages for your validation.
$this->assertAuthorized() To assert that request have been authorized via the form request.
$this->assertNotAuthorized() To assert that request have not been authorized via the form request.
$this->assertValidationData($keysArray) To assert that the keys mentioned in the $keysArray have occurred in the validated data.
$this->assertValidationDataMissing($keysArray) To assert that the keys mentioned in the $keysArray have not occurred in the validated data.

Example Usage:

Taking into consderation:

  1. title & content are required field,
  2. Content field is required is a custom error message used for content field
  3. $this->route method is used in authorize method
  4. Route::put('posts/{post}', 'PostsController@update') is the route used to update a post

you can now use intuitive methods to build form request

Form Requests related methods and how to work with them

$this->route('parameter'):

This method basically retreive the value of a routing rule parameter.

For example if you have a routing rule put posts/{post} and browsed to posts/1 then the value of $this->route('post') is 1. for this to work with the package you need to

  1. Register the routing rule in your application routing files web.php or api.php

  2. set the route using FormRequestTester withRoute method

this why when you use the $this->route('post') in your form request, the result will be 1.

The package also supports substitube binding. All you need to be is to ؤreate an explicit binding and will do the work for you.

when you do the reigster, the value of $this->route('post') will be a Post model rather than the id.

Alternatively

if you don't want to register a route just for the sake of resolving a route parameter then you can use FormRequestTester addRouteParameter($name, $value).

according to the example above, with the new method addRouteParameter, $this->route('post') will be resolved to 1

$this->user():

This method will reteive the current authenticated user.

use laravel testing method actingAs to set a user as the current authenticated user

Contributors:

  1. Mohammed Manssour
  2. Bryan Pedroza
  3. Kyler Moore

All versions of form-request-tester with dependencies

PHP Build Version
Package Version
No informations.
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 mohammedmanssour/form-request-tester contains the following files

Loading the files please wait ....