Unit testing allows the programmer to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly (e.g., in regression testing). The procedure is a critical element of extreme programming, which relies on frequent releases in short development cycles and emphasizes comprehensive unit testing to ensure application stability. Mock objects can be used as a replacement for real objects in unit testing, they often also record how they were used so that you can make assertions about this after the test has finished. Let's see the 14 best PHP Mock libraries in 2022, mockery - simple yet flexible PHP mock object framework; prophecy - Highly opinionated mocking framework for PHP 5.3; phpunit-mock-objects Mock Object library for PHPUnit.
mockeryby 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).
mockeryby mockery
PHP 10406 Version:1.5.1 License: Others (Non-SPDX)
prophecyby phpspec
Highly opinionated mocking framework for PHP 5.3+
prophecyby phpspec
PHP 8544 Version:v1.17.0 License: Permissive (MIT)
phpunit-mock-objectsby sebastianbergmann
Mock Object library for PHPUnit
phpunit-mock-objectsby sebastianbergmann
PHP 5027 Version:1.2.3 License: Others (Non-SPDX)
vfsStreamby bovigo
vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.
vfsStreamby bovigo
PHP 1364 Version:v1.6.11 License: Permissive (BSD-3-Clause)
AspectMockby Codeception
The most powerful and flexible mocking framework for PHPUnit / Codeception.
AspectMockby Codeception
PHP 758 Version:4.1.1 License: Permissive (MIT)
http-mockby InterNations
Mock HTTP requests on the server side in your PHP unit tests
http-mockby InterNations
PHP 387 Version:Current License: Permissive (MIT)
soft-mocksby badoo
PHP mocks engine that allows to redefine functions and user methods on-the-fly (provides similar functionality to runkit and uopz extensions)
soft-mocksby badoo
PHP 302 Version:3.1.1 License: Permissive (MIT)
BrainMonkeyby Brain-WP
Mocking utility for PHP functions and WordPress plugin API
BrainMonkeyby Brain-WP
PHP 267 Version:2.6.1 License: Permissive (MIT)
php-mock-phpunitby php-mock
Mock built-in PHP functions (e.g. time() or rand()) in PHPUnit.
php-mock-phpunitby php-mock
PHP 147 Version:2.7.1 License: Permissive (WTFPL)
mock-webserverby donatj
Simple mock web server in PHP for unit testing.
mock-webserverby donatj
PHP 115 Version:v2.6.1 License: Permissive (MIT)