# Mockery

> Mock object framework for PHP unit tests

Source: https://talira.ai/catalog/mockery-1wmr5g8e
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [developer tools / testing / mocking](https://talira.ai/categories/developer-tools/testing/mocking)
- Licence: BSD-3-Clause[^1]
- Pricing: Free and open source
- Free tier: yes
- Backed by: [Mockery](https://talira.ai/orgs/mockery.md)

Mockery is a mock object framework for PHP: Mockery::mock creates a test double, optionally of a class or interface so it satisfies type hints, and a readable DSL declares the method calls it expects, their arguments and what they return. It also makes spies and partial mocks. It works with PHPUnit, PHPSpec or any other test framework, and ships PHPUnit helpers (a MockeryTestCase base class and traits) that verify expectations after each test. It began as an alternative to PHPUnit's own phpunit-mock-objects and can run alongside it.

## Links

- GitHub: https://github.com/https://github.com/mockery/mockery
- Docs: https://docs.mockery.io/en/stable/

## Problems it solves

- fake a dependency in my PHP unit tests
- check that a PHP method was called with the right arguments
- stub a class's return values in a PHPUnit test

## Features

- mocks of classes and interfaces
- expectation DSL for calls, arguments and return values
- spies and partial mocks
- PHPUnit integration helpers
- works with any test framework

## Trust

Overall: 0.53 out of 1.
Signals: maintenance 0.50, adoption 0.81, momentum 0.52, community 0.96, backing 0.30, extensibility 0.00.

- last commit 37 days ago
- 8 commits in the last 90 days
- latest release 1.6.15 3 months ago
- 10.7k GitHub stars
- 254 contributors
- has a company behind it

## Sources

[^1]: https://github.com/mockery/mockery/blob/1.6.x/LICENSE (checked 23 Nov 2026)
