PHPackages                             phpspec/prophecy-phpunit - 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. phpspec/prophecy-phpunit

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

phpspec/prophecy-phpunit
========================

Integrating the Prophecy mocking library in PHPUnit test cases

v2.5.0(3mo ago)19454.9M—4.7%42[1 issues](https://github.com/phpspec/prophecy-phpunit/issues)[2 PRs](https://github.com/phpspec/prophecy-phpunit/pulls)20MITPHPPHP ^7.3 || ^8CI passing

Since Jul 4Pushed 3mo ago14 watchersCompare

[ Source](https://github.com/phpspec/prophecy-phpunit)[ Packagist](https://packagist.org/packages/phpspec/prophecy-phpunit)[ Docs](http://phpspec.net)[ RSS](/packages/phpspec-prophecy-phpunit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (20)

Prophecy
========

[](#prophecy)

[![Build Status](https://github.com/phpspec/prophecy-phpunit/actions/workflows/ci.yml/badge.svg)](https://github.com/phpspec/prophecy-phpunit/actions/workflows/ci.yml)

Prophecy PhpUnit integrates the [Prophecy](https://github.com/phpspec/prophecy) mocking library with [PHPUnit](https://phpunit.de) to provide an easier mocking in your testsuite.

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

[](#installation)

### Prerequisites

[](#prerequisites)

Prophecy PhpUnit requires PHP 7.3 or greater. Prophecy PhpUnit requires PHPUnit 9.1 or greater. Older versions of PHPUnit are providing the Prophecy integration themselves.

### Setup through composer

[](#setup-through-composer)

```
composer require --dev phpspec/prophecy-phpunit
```

You can read more about Composer on its [official webpage](https://getcomposer.org).

How to use it
-------------

[](#how-to-use-it)

The trait `ProphecyTrait` provides a method `prophesize($classOrInterface = null)` to use Prophecy. For the usage of the Prophecy doubles, please refer to the [Prophecy documentation](https://github.com/phpspec/prophecy).

Below is a usage example:

```
