| 148 |
lars |
1 |
Mockery
|
|
|
2 |
=======
|
|
|
3 |
|
|
|
4 |
Mockery is a simple yet flexible PHP mock object framework for use in unit
|
|
|
5 |
testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is
|
|
|
6 |
to offer a test double framework with a succinct API capable of clearly
|
|
|
7 |
defining all possible object operations and interactions using a human
|
|
|
8 |
readable Domain Specific Language (DSL). Designed as a drop in alternative to
|
|
|
9 |
PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with
|
|
|
10 |
PHPUnit and can operate alongside phpunit-mock-objects without the World
|
|
|
11 |
ending.
|
|
|
12 |
|
|
|
13 |
Mock Objects
|
|
|
14 |
------------
|
|
|
15 |
|
|
|
16 |
In unit tests, mock objects simulate the behaviour of real objects. They are
|
|
|
17 |
commonly utilised to offer test isolation, to stand in for objects which do
|
|
|
18 |
not yet exist, or to allow for the exploratory design of class APIs without
|
|
|
19 |
requiring actual implementation up front.
|
|
|
20 |
|
|
|
21 |
The benefits of a mock object framework are to allow for the flexible
|
|
|
22 |
generation of such mock objects (and stubs). They allow the setting of
|
|
|
23 |
expected method calls and return values using a flexible API which is capable
|
|
|
24 |
of capturing every possible real object behaviour in way that is stated as
|
|
|
25 |
close as possible to a natural language description.
|
|
|
26 |
|
|
|
27 |
Getting Started
|
|
|
28 |
---------------
|
|
|
29 |
|
|
|
30 |
Ready to dive into the Mockery framework? Then you can get started by reading
|
|
|
31 |
the "Getting Started" section!
|
|
|
32 |
|
|
|
33 |
.. toctree::
|
|
|
34 |
:hidden:
|
|
|
35 |
|
|
|
36 |
getting_started/index
|
|
|
37 |
|
|
|
38 |
.. include:: getting_started/map.rst.inc
|
|
|
39 |
|
|
|
40 |
Reference
|
|
|
41 |
---------
|
|
|
42 |
|
|
|
43 |
The reference contains a complete overview of all features of the Mockery
|
|
|
44 |
framework.
|
|
|
45 |
|
|
|
46 |
.. toctree::
|
|
|
47 |
:hidden:
|
|
|
48 |
|
|
|
49 |
reference/index
|
|
|
50 |
|
|
|
51 |
.. include:: reference/map.rst.inc
|
|
|
52 |
|
|
|
53 |
Mockery
|
|
|
54 |
-------
|
|
|
55 |
|
|
|
56 |
Learn about Mockery's configuration, reserved method names, exceptions...
|
|
|
57 |
|
|
|
58 |
.. toctree::
|
|
|
59 |
:hidden:
|
|
|
60 |
|
|
|
61 |
mockery/index
|
|
|
62 |
|
|
|
63 |
.. include:: mockery/map.rst.inc
|
|
|
64 |
|
|
|
65 |
Cookbook
|
|
|
66 |
--------
|
|
|
67 |
|
|
|
68 |
Want to learn some easy tips and tricks? Take a look at the cookbook articles!
|
|
|
69 |
|
|
|
70 |
.. toctree::
|
|
|
71 |
:hidden:
|
|
|
72 |
|
|
|
73 |
cookbook/index
|
|
|
74 |
|
|
|
75 |
.. include:: cookbook/map.rst.inc
|
|
|
76 |
|