PHPackages                             elmpp/mockery - 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. elmpp/mockery

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

elmpp/mockery
=============

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.

0.9.4(11y ago)033BSD-3-ClausePHPPHP &gt;=5.3.2

Since Jan 24Pushed 10y agoCompare

[ Source](https://github.com/elmpp/mockery)[ Packagist](https://packagist.org/packages/elmpp/mockery)[ Docs](http://github.com/padraic/mockery)[ RSS](/packages/elmpp-mockery/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

Mockery
=======

[](#mockery)

[![Build Status](https://camo.githubusercontent.com/00869e608e89fe5d1761176d579d36352522f9adeb1d54650e445c09359507f8/68747470733a2f2f7472617669732d63692e6f72672f706164726169632f6d6f636b6572792e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/padraic/mockery)[![Latest Stable Version](https://camo.githubusercontent.com/b6b3c997b8ef82d7e7805a24e94c2a4a61e8c0b757ab8524d511c2e8b4a2ef66/68747470733a2f2f706f7365722e707567782e6f72672f6d6f636b6572792f6d6f636b6572792f762f737461626c652e706e67)](https://packagist.org/packages/mockery/mockery)[![Total Downloads](https://camo.githubusercontent.com/393e197924e8e7580b5526c4e28eacbb0a5ff7003288c032103d01d4604c3e48/68747470733a2f2f706f7365722e707567782e6f72672f6d6f636b6572792f6d6f636b6572792f646f776e6c6f6164732e706e67)](https://packagist.org/packages/mockery/mockery)

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.

Mockery is released under a New BSD License.

The current released version on Packagist is `0.9.4`. The current released version for PEAR is `0.9.0`. Composer users may instead opt to use the current master branch aliased to `1.0.x-dev`.

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

[](#installation)

To install Mockery, run the command below and you will get the latest version

```
composer require --dev mockery/mockery
```

If you want to run the tests:

```
vendor/bin/phpunit
```

\####Note

The current Mockery 0.9.4 release is the final version to have PHP 5.3 as a minimum requirement. The minimum PHP requirement has been moved to PHP 5.4 for future releases. Also, the PEAR channel will go offline permanently no earlier than 30 June 2015.

Mock Objects
------------

[](#mock-objects)

In unit tests, mock objects simulate the behaviour of real objects. They are commonly utilised to offer test isolation, to stand in for objects which do not yet exist, or to allow for the exploratory design of class APIs without requiring actual implementation up front.

The benefits of a mock object framework are to allow for the flexible generation of such mock objects (and stubs). They allow the setting of expected method calls and return values using a flexible API which is capable of capturing every possible real object behaviour in way that is stated as close as possible to a natural language description.

Prerequisites
-------------

[](#prerequisites)

Mockery requires PHP 5.3.2 or greater for versions `0.9.4` or lower. The current master and future versions will use PHP 5.4 at minimum. This is subject to change as PHP versions reach their published end of life dates.

Documentation
-------------

[](#documentation)

The current version can be seen at [docs.mockery.io](http://docs.mockery.io).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~105 days

Total

7

Last Release

4060d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c423516d8d973ae842e7fca7089a396135a76092b5b7174f366569b1eb317838?d=identicon)[elmpp](/maintainers/elmpp)

---

Top Contributors

[![davedevelopment](https://avatars.githubusercontent.com/u/61351?v=4)](https://github.com/davedevelopment "davedevelopment (393 commits)")[![padraic](https://avatars.githubusercontent.com/u/19780?v=4)](https://github.com/padraic "padraic (132 commits)")[![fhinkel](https://avatars.githubusercontent.com/u/101553?v=4)](https://github.com/fhinkel "fhinkel (27 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (25 commits)")[![robertbasic](https://avatars.githubusercontent.com/u/166625?v=4)](https://github.com/robertbasic "robertbasic (18 commits)")[![fredemmott](https://avatars.githubusercontent.com/u/360927?v=4)](https://github.com/fredemmott "fredemmott (8 commits)")[![asmblah](https://avatars.githubusercontent.com/u/1714005?v=4)](https://github.com/asmblah "asmblah (8 commits)")[![wouterj](https://avatars.githubusercontent.com/u/749025?v=4)](https://github.com/wouterj "wouterj (8 commits)")[![beni0888](https://avatars.githubusercontent.com/u/2619784?v=4)](https://github.com/beni0888 "beni0888 (6 commits)")[![yugeon](https://avatars.githubusercontent.com/u/350226?v=4)](https://github.com/yugeon "yugeon (5 commits)")[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (5 commits)")[![agiledivider](https://avatars.githubusercontent.com/u/1173523?v=4)](https://github.com/agiledivider "agiledivider (5 commits)")[![demsey2](https://avatars.githubusercontent.com/u/3159367?v=4)](https://github.com/demsey2 "demsey2 (5 commits)")[![adambrett](https://avatars.githubusercontent.com/u/145340?v=4)](https://github.com/adambrett "adambrett (4 commits)")[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (4 commits)")[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (4 commits)")[![villfa](https://avatars.githubusercontent.com/u/2891564?v=4)](https://github.com/villfa "villfa (4 commits)")[![gordalina](https://avatars.githubusercontent.com/u/787913?v=4)](https://github.com/gordalina "gordalina (3 commits)")[![lytc](https://avatars.githubusercontent.com/u/788101?v=4)](https://github.com/lytc "lytc (3 commits)")[![srosato](https://avatars.githubusercontent.com/u/650192?v=4)](https://github.com/srosato "srosato (3 commits)")

---

Tags

testingtestlibraryBDDTDDmockerymockstubtest doublemock objects

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elmpp-mockery/health.svg)

```
[![Health](https://phpackages.com/badges/elmpp-mockery/health.svg)](https://phpackages.com/packages/elmpp-mockery)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)[php-mock/php-mock-mockery

Mock built-in PHP functions (e.g. time()) with Mockery. This package relies on PHP's namespace fallback policy. No further extension is needed.

392.1M96](/packages/php-mock-php-mock-mockery)[kahlan/kahlan

The PHP Test Framework for Freedom, Truth and Justice.

1.2k1.2M247](/packages/kahlan-kahlan)[php-mock/php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

16496.6k15](/packages/php-mock-php-mock-prophecy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
