PHPackages                             zalas/phpunit-doubles - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. zalas/phpunit-doubles

ActiveLibrary[Testing &amp; Quality](/categories/testing)

zalas/phpunit-doubles
=====================

Initialises test doubles in PHPUnit test cases for you

v1.9.8(8mo ago)1513.3k22MITPHPPHP ~8.3.0 || ~8.4.0CI passing

Since Jul 27Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/jakzal/phpunit-doubles)[ Packagist](https://packagist.org/packages/zalas/phpunit-doubles)[ GitHub Sponsors](https://github.com/jakzal)[ RSS](/packages/zalas-phpunit-doubles/feed)WikiDiscussions 1.9 Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (30)Used By (2)

PHPUnit Doubles
===============

[](#phpunit-doubles)

[![Build](https://github.com/jakzal/phpunit-doubles/actions/workflows/build.yml/badge.svg)](https://github.com/jakzal/phpunit-doubles/actions/workflows/build.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/adfd4ef02436da4a3f46a45caf7461b41ecaa72be8d829b0c5ba91d3a5b5728f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a616b7a616c2f706870756e69742d646f75626c65732f6261646765732f7175616c6974792d73636f72652e706e673f623d312e39)](https://scrutinizer-ci.com/g/jakzal/phpunit-doubles/?branch=1.9)

Initialises test doubles in PHPUnit test cases for you.

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require --dev zalas/phpunit-doubles
```

### Phar

[](#phar)

The extension is also distributed as a PHAR, which can be downloaded from the most recent [Github Release](https://github.com/jakzal/phpunit-doubles/releases).

Put the extension in your PHPUnit extensions directory. Remember to instruct PHPUnit to load extensions in your `phpunit.xml`:

```

```

Usage
-----

[](#usage)

Include the `Zalas\PHPUnit\Doubles\TestCase\ProphecyTestDoubles` or `Zalas\PHPUnit\Doubles\TestCase\PHPUnitTestDoubles`trait to have your test doubles initialised in one of the supported test doubling frameworks.

Both the type of test double and the kind of test doubling framework are taken from the property type:

```
/**
 * @var Vimes|ObjectProphecy
 */
 private $vimes;
```

Currently, two test doubling frameworks are supported:

- [Prophecy](https://github.com/phpspec/prophecy) - `Prophecy\Prophecy\ObjectProphecy` type hint
- [PHPUnit](https://phpunit.de/manual/current/en/test-doubles.html) - `PHPUnit\Framework\MockObject\MockObject` type hint

### Prophecy

[](#prophecy)

```
