Download the PHP package michalv8/xpmock without Composer
On this page you can find all versions of the php package michalv8/xpmock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download michalv8/xpmock
More information about michalv8/xpmock
Files in michalv8/xpmock
Package xpmock
Short Description PHPUnit: simple syntax to create mock-objects
License MIT
Informations about the package xpmock
xpmock
Introduction [in English] [на русском]
!!! New version 1.1.5: multiple improvements
PHPUnit is standard testing framework in PHP world. No wonder - it is nifty. But speaking about way of mocking objects in PHPUnit many people complain on a bit redundant syntax. They suggest many addons for PHPUnit to create mocks like Mockery (I know this is not just addon).
But I am sure PHPUnit has well-developed mocking system. And this project XPMock is a way to simplify this syntax a bit. I need to underline that XPMock doesn't create some own mock objects. XPMock just calls the same PHPUnit methods creating the same native mocks but much simpler.
Write this
instead of that
Tool generates full-functional native PHPUnit mocks.
Syntax short description
Handy reflection methods
Installation
- If you don't have composer, install it
- Add xpmock to your project
Usage
Option 1. Add trait to existing test case:
OR Option 2. Extend your test case from xpmock's one:
NEW
-
If you need to create object with some methods and classname doesn't matter, you could easily do it like this:
- Mocking static methods
- Mocking abstract methods
-
Brief syntax to create mocks
-
Special method this() inside each mock gives you possibility to change non-public properties and call non-public methods of mock via Xpmock\Reflection
-
You can use $this pointer inside your fake methods
-
It is easy now to create mocks all methods of which return some value, for example null (stub)
- Very expected: now it is possible to adjust mocks after creation with magic method mock()