Mock object framework for PHP unit tests
open sourceBSD-3-Clausefree
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.
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