Download the PHP package facile-it/moka without Composer

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

Moka - Shorthand for Creating Mock Objects

GitHub release Travis Scrutinizer Coverage Scrutinizer Packagist

Tired of spending most of your testing time mocking objects like there's no tomorrow? Yes.
Moka provides you with two simple methods to reduce your effort on such a tedious task, and with an incredible abstraction layer between the most popular mock engines and you.

Installation

You can install the package via composer:

Usage

To use Moka in your tests simply use function Moka\Plugin\PHPUnit\moka() (see generators section below) and run Moka::clean() before every test. A simple interface will let you create moka (mock) objects and decorate them with stub methods and properties via a fluent interface:

Alternatively, instead of using moka(), you can call Moka::phpunit(string $fqcnOrAlias, string $alias = null): ProxyInterface.

Being such a simple project, Moka can be integrated in an already existing test suite with no effort.

Notice: if you are extending PHPUnit TestCase, to simplify the cleaning phase we provide a MokaCleanerTrait which automatically runs Moka::clean() after each test.

You can rely on the original mock object implementation to be accessible (in the example below, PHPUnit's - for Prophecy see below):

Reference

moka(string $fqcnOrAlias, string $alias = null): ProxyInterface

Creates a proxy containing a mock object (according to the selected strategy) for the provided FQCN and optionally assigns an $alias to it to be able to get it later:

The $alias allows you to store mock instances:

ProxyInterface::stub(array $namesWithValues): ProxyInterface

Accepts an array of method or property stubs with format [$name => $value], where $name must be a string and $value can be of any type, including another mock object.

Caution:

Notice: method stubs are valid for any invocation of the defined methods and cannot be overridden.
If you need more granular control over invocation strategies, you can get access to the original mock object implementation.

Supported mock object generators

Currently we ship Moka with built-in support for PHPUnit mock objects.
We support other generators as well, but you need to install the relevant packages to make them work:

We provide a specific moka() function for each supported strategy, as well as a static method (self documented in the function itself):

Prophecy native behavior

Prophecy lets you stub methods by calling them directly on the ObjectProphecy. Moka doesn't support such a behavior, but we provide an easy workaround:

Warning: this workaround cannot be used with methods having the same name as a previously stubbed property:

Plugin development

If you feel a genius and want to create your own mock generator (or add support for an existing one), just implement Moka\Plugin\PluginInterface and the relative Moka\Strategy\MockingStrategyInterface:

Extend AbstractMockingStrategy for an easier (and stricter) implementation of your strategy:

Warning: your plugin FQCN must match the template Moka\Plugin\YourOwn\YourOwnPlugin, where YourOwn is the name of the plugin.
Both your plugin and your strategy must pass our test cases (please install phpunit/phpunit to run them):

Let us know of any Moka-related development!

Testing

We highly suggest using Paraunit for a faster execution of tests:

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of moka with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
phpcollection/phpcollection Version ^0.5
phpunit/phpunit Version ^7.0
psr/container Version ^1.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 facile-it/moka contains the following files

Loading the files please wait ....