Download the PHP package pbweb/mimic without Composer

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

Mimic

This library can be used to create mimics of your classes, which can be used for (functional) testing.

A mimicked class is similar to mock objects with stub methods in phpunit, but on a functional level.

Installation

Install with composer

Install mimic using composer:

Example

Lets say you have a client class which talks to an external REST service. The interface might look like this:

Now, using a class which really connects to the REST server in a (functional) test is a bad idea, since that server may not be in the scope of your test and influence the results.

To create a mimic client you need to extend MimicActionHandler like this:

Now you can mimic the behaviour of the RestClient in your tests:

Argument Matchers

In case you want more control over the arguments that are expected for a call, you can use argument matchers.

The ArgumentMatchers class instantiates several matchers which can be passed to the expected argument list of enqueue.

Usage

Extending MimicActionHandler will allow your class to have the mimic enqueue system. Every method you want to mimic should have this as the body:

See tests/Service/SampleMimic for an example.

enableQueue

enableQueue will enable the use of the queue.

disableQueue

disableQueue will stop the use of the queue.

isQueueEnabled

isQueueEnabled will return a boolean value with the state of the queue.

enqueue

enqueue will add a method call to the expected queue. You can add as many method prediction as you like. If the next call to the mimic is the expected call then the given response will be returned and it will be removed from the queue. If the next call to the mimic is not the same as the expected call added to the queue then an exception will be thrown.

If you set throw to true then the response will be thrown instead of returned.

getQueueContent

getQueueContent will return all the remaining actions added to the queue as Action models. See the Action class for more information about the model.

isFinished

isFinished will return true if there are no more action left in the queue. false otherwise.

clearQueue

clearQueue will remove all the remaining actions from the queue.


All versions of mimic with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
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 pbweb/mimic contains the following files

Loading the files please wait ....