Yay! Mock
A standalone mock object library for PHP 5 (based on jMock)
Yay! Mock aims to be a test framework-independent mock object library with the most flexibility possible. Based on jMock (Java) it makes expectations based on Invocation signatures rather than just on method names and/or call timings.
Mock objects only contain the methods of the original type they mock. In other words, mock objects created with Yay! Mock do not have any expectation methods embedded inside them; instead they "record" invocations to the context in which they were created.
Yay! Mock encourages dependency injection and loose coupling without pushing you into corners of testing implementation details. It works with any unit testing framework.
Particular features include
- Mock interfaces (preferred) or classes
- Object identities via type-hints remain integral
- Expect invocations based on signatures
- Specify return values for specific invocation signatures
- Specify actions to perform on specific invocation signatures
- Match signatures loosely based on various Matchers
- Expect invocations when the environment is in a specific state
- Expect sequences of Invocations
Yay! Mock code (like jMock) is intended to be easy to learn and to understand when read. The code written within test cases is very fluent and expressive.
The current development status is beta 3