phpunit/phpunit-mock-objects
Default mock object library for PHPUnit. Create test doubles (mocks, stubs, spies) to isolate units under test, define expectations, control method returns, and verify interactions. Designed for PHPUnit projects and compatible with PHP 7.1+.
|
Package
|
Score
|
Description
|
Stars
|
Likes
|
Forks
|
Downloads
|
Issues
|
Score
|
Opportunity
|
License
|
Last Release
|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| codeception/stub | 0.89 | Create lightweight test doubles for PHP with Codeception Stub. Quickly generate stubs and mocks, define method returns and expectations, and override behavior on the fly—ideal for unit tests that need fast, flexible objects without full implementations. | 301 | 302 | 19 | 1M | 7 | 22.0 | 57.4 | MIT | 9 months ago | |
| php-mock/php-mock | 0.88 | Mock built-in PHP functions like time() or rand() in tests by leveraging PHP’s namespace fallback: define namespaced replacements for unqualified calls. Works in non-global namespaces; supports common test frameworks via integrations (e.g., PHPUnit). | 370 | 375 | 19 | 726K | 3 | 13.0 | 47.8 | WTFPL | 9 months ago | |
| php-mock/php-mock-mockery | 0.87 | Integrates php-mock with Mockery to mock PHP built-in functions in tests. Create namespaced function mocks with PHPMockery::mock() and set expectations/returns, then call Mockery::close(). Supports only unqualified calls; define early if needed. | 39 | 39 | 5 | 78K | 2 | 1.9 | 45.4 | WTFPL | 1 year ago | |
| pestphp/pest-plugin-mock | 0.87 | Pest plugin that integrates Mockery into Pest tests, providing convenient helpers to create, configure, and verify mocks and spies with a simple, Pest-friendly API for unit and feature testing in PHP/Laravel projects. | 17 | 15 | 10 | 9K | 0 | 0.2 | 26.4 | MIT | — | |
| reecem/mocker | 0.87 | A lightweight Laravel-friendly mocking helper for PHP tests. Quickly define and swap mocks, set expectations, and control return values to simplify unit and feature testing. Designed to reduce boilerplate and keep test setup clean and readable. | 7 | 7 | 16 | 2K | 2 | 4.3 | 33.2 | MIT | 3 years ago | |
| mnapoli/phpunit-easymock | 0.87 | A lightweight bridge between PHPUnit and EasyMock for PHP. Quickly create, replay, and verify mocks from your test cases with minimal boilerplate, helping you write clear unit tests using the familiar EasyMock-style workflow. | 38 | 38 | 4 | 1K | 0 | 4.8 | 20.6 | MIT | 1 year ago | |
| janmarek/mockista | 0.87 | Mockista is a lightweight mocking library for PHP/Laravel that helps you create and configure test doubles quickly. Define expectations, stub methods, and verify calls with a simple, fluent API to keep unit tests fast, readable, and maintainable. | 29 | 29 | 14 | 248 | 2 | 1.4 | 14.9 | — | — | |
| php-mock/php-mock-integration | 0.87 | Integration layer for php-mock, making it easy to use PHP function mocks within popular test frameworks. Helps you stub built-in functions like time(), rand(), and file operations in specific namespaces, enabling reliable, isolated unit tests without touching global state. | 14 | 14 | 6 | 374K | 0 | 8.2 | 57.8 | WTFPL | 9 months ago | |
| phpspec/prophecy | 0.86 | Highly opinionated yet flexible PHP mocking framework for unit tests. Create test doubles with a Prophet, define expected calls and return values, then reveal mocks and verify predictions. Works with PHPUnit and other frameworks; requires PHP 7.2+. | 8,462 | 8,498 | 245 | 3M | 89 | 67.7 | 61.3 | MIT | 8 months ago | |
| php-http/mock-client | 0.86 | Mock HTTP client for HTTPlug/PHP-HTTP. Stores outgoing requests and returns queued responses or throws exceptions instead of making real network calls—ideal for unit tests of HTTP-dependent code. Install via Composer as a dev dependency. | 71 | 75 | 16 | 266K | 0 | 6.0 | 49.3 | MIT | 2 years ago | |
| php-mock/php-mock-phpunit | 0.86 | Integrate php-mock with PHPUnit to mock built-in PHP functions (like time(), file_get_contents(), etc.) in a controlled, namespaced way. Ideal for unit tests that need to simulate IO, time, and other global behaviors without changing production code. | 173 | 176 | 20 | 236K | 4 | 28.3 | 51.3 | WTFPL | 1 month ago | |
| lendable/phpunit-extensions | 0.86 | — | 2 | 2 | 0 | 2K | 1 | 8.6 | 43.2 | MIT | 8 months ago | |
| php-mock/php-mock-prophecy | 0.86 | Prophecy integration for php-mock lets you mock PHP built-in functions like time, rand, and sleep inside Prophecy test doubles. Define expected behavior for global functions alongside class mocks, making time-dependent code testable without hard dependencies. | 16 | — | 4 | — | 0 | 1.5 | — | WTFPL | 11 months ago |
|
| sanmai/phpunit-legacy-adapter | 0.85 | Compatibility adapter for running legacy PHPUnit test suites on newer PHPUnit versions. Helps bridge API changes, keep older tests passing, and smooth migrations without rewriting everything. Suitable for maintaining long-lived PHP projects with outdated test setups. | 3 | 3 | 1 | 450 | 0 | 13.3 | 31.0 | Apache-2.0 | 6 months ago | |
| pkly/phpunit-service-create-trait | 0.85 | A PHPUnit 12+ trait (PHP 8.4+) that builds real service instances with auto-mocked constructor and #[Required] dependencies. Dependencies stay as invisible stubs until fetched, so you only get mock verification where you ask for it. | 0 | 0 | 0 | 289 | 0 | 20.8 | 39.4 | MIT | 1 month ago | |
| eloquent/phony-phpunit | 0.85 | Integration of the Phony mocking/stubbing library with PHPUnit, providing helpers to use Phony in your test suite. Note: this package is no longer maintained; see the linked statement and consider alternatives or the main Phony repo. | 6 | 6 | 3 | 713 | 0 | 1.6 | 19.7 | MIT | 5 years ago | |
| phpspec/prophecy-phpunit | 0.85 | Integrates the Prophecy mocking library with PHPUnit for simpler, cleaner test doubles. Install via Composer and use the ProphecyTrait to call prophesize() inside your TestCase, set method predictions/returns, and reveal mocks for injection. | 195 | 195 | 39 | 1M | 1 | 11.7 | 56.7 | MIT | 8 months ago | |
| phpstan/phpstan-phpunit | 0.85 | PHPStan extension for PHPUnit that improves mock object and assert type inference, supports MockBuilder and phpDoc intersections, and adds optional strict rules for more precise, framework-aware static analysis. | 546 | 550 | 58 | 6M | 34 | 44.3 | 79.3 | MIT | 4 weeks ago | |
| mockery/mockery | 0.85 | Mockery is a flexible PHP mock object framework for unit testing with PHPUnit, PHPSpec, or any other testing framework. It offers a succinct, human-readable DSL for defining test doubles and integrates easily as a drop-in alternative to PHPUnit's mocking library. | 10,724 | 10,808 | 470 | 19M | 89 | 84.3 | 77.1 | BSD-3-Clause | 2 months ago | |
| phpunitgoodpractices/traits | 0.84 | A small set of PHP traits to improve PHPUnit test code by reducing boilerplate and encouraging cleaner, reusable assertions and setup patterns. Useful for Laravel and general PHP projects that want more readable, maintainable tests. | 21 | 22 | 1 | 15K | 3 | 2.6 | 28.1 | MIT | 4 years ago |
How can I help you explore Laravel packages today?