Download the PHP package jcid/phpunit-mock-extension without Composer

On this page you can find all versions of the php package jcid/phpunit-mock-extension. 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 phpunit-mock-extension

PHP Unit Mock Extension

An PHP extension to allow multiple calls to a method with different counts and different arguments.

Installation

The problem

Currently if you want to do multiple method calls to a PHP Unit mock object with different argument and return statements you can to use the $this->at($index) method. The problem with this method is that you cannot check if the method is getting called to much for instance a third time like in the example below. This is the case because PHP Unit does not use the arguments to select the matcher.

An other solution is to use the logic or method's to define the arguments. But I personally don't like this method because it decouples the arguments from the return values and you have no control over the sequence or combination of arguments and returns.

But there is a third solution provided by PHP Unit the $this->returnValueMap(*array*) method. This method is a bit strange because the last argument of the array is the return value. But it couples the arguments and the return values and that's nice. You can now also check the amount of times the method is called with the right combination.

The second problem with the $this->returnValueMap(*array*) method is that the arguments use a strict comparison check and if you use a value holder like we do this will fail.

Our solution

We created this library which uses a custom MockObject Matcher and custom MockObject to decide how and how much times we should return a specific value. The idea is based on the idea of $this->at($index) but has al the features we want.

We use a custom builder to create the sequence of calls to one particular method and then define the expects with our custom matcher created by the builder and the use the return stub provided by it.

Inspiration

This library is inspired by etsy/phpunit-extensions


All versions of phpunit-mock-extension with dependencies

PHP Build Version
Package Version
Requires php Version ~5.6 | ~7.0
phpunit/phpunit Version ^5.1
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 jcid/phpunit-mock-extension contains the following files

Loading the files please wait ....