Download the PHP package watson/testing without Composer

On this page you can find all versions of the php package watson/testing. 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 testing

Testing, PHPUnit helpers for Laravel

This package is no longer maintained, in favour of better testing support now shipping with Laravel.

Testing contains traits with helpers for testing models and controllers in Laravel. It helps you assert the validity of your models (assuming the use of watson/validating) as well as the relationships of your models. It also allows you to test the responses of your controllers.

Installation

Simply run the following Composer command in your application.

The ~1.0 stream is for Laravel 4, and the ~2.0 stream is for Laravel 5.

Overview

To use the test helpers in your tests, simply bring the trait in to your test file.

If you'd prefer to use the test helpers globally, just use this trait in your TestCase.php.

Controller testing

assertViewIs($expectedView, $message = null);

Ensure that the view used in the response is the one you expected.

Model testing

Model validations

If you're using watson/validating on your models it is really easy to test your validations. We will use the following User model for these examples.

assertValid(Model $model, $message = null)

assertInvalid(Model $model, $message = null)

If you want to easily check if a model is valid or invalid with or without a certain attribute, there a number of helpers for quickly asserting that this is the case.

assertValidWith(Model $model, $attribute, $value = null, $message = null)

assertValidWithout(Model $model, $attribute, $message = null)

assertInvalidWith(Model $model, $attribute, $value = null, $message = null)

assertInvalidWithout(Model $model, $attribute, $message = null)

Specific model validations

If you'd prefer an easier (and more readable) way of asserting the validations on your model you might like to try specific model validations. They work with watson/validating or any other validation trait that complies with Watson\Validating\ValidatingInterface (that is, has a getDefaultRules method).

assertValidatesWith(Model $mode, $attribute, $rule, $message = null)

Here is the list of included Laravel default validation assertions:

Model relationships

You can assert the different relationships exist on your model.

assertBelongsTo($class, $relation)

Ensure that a post belongs to a user.

assertBelongsToMany($class, $relation)

Ensure that a tag belongs to many posts.

assertHasOne($class, $relation)

Ensure that a user has one profile.

assertHasMany($class, $relation)

Ensure that a user has many posts.

Credits

This package builds upon the work of the now unmaintained way/laravel-test-helpers and includes code from the unmerged pull requests of SammyK, effi, mrevd and sorora.

I decided to continue the development of these helpers because I prefer testing with the tool that ships with the framework, and I really like PHPUnit.


All versions of testing with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
mockery/mockery Version 0.9.*
illuminate/database Version ~5.0
illuminate/support Version ~5.0
phpunit/phpunit Version ~4.5
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 watson/testing contains the following files

Loading the files please wait ....