| 148 |
lars |
1 |
.. index::
|
|
|
2 |
single: Reserved Method Names
|
|
|
3 |
|
|
|
4 |
Reserved Method Names
|
|
|
5 |
=====================
|
|
|
6 |
|
|
|
7 |
As you may have noticed, Mockery uses a number of methods called directly on
|
|
|
8 |
all mock objects, for example ``shouldReceive()``. Such methods are necessary
|
|
|
9 |
in order to setup expectations on the given mock, and so they cannot be
|
|
|
10 |
implemented on the classes or objects being mocked without creating a method
|
|
|
11 |
name collision (reported as a PHP fatal error). The methods reserved by
|
|
|
12 |
Mockery are:
|
|
|
13 |
|
|
|
14 |
* ``shouldReceive()``
|
|
|
15 |
* ``shouldNotReceive()``
|
|
|
16 |
* ``allows()``
|
|
|
17 |
* ``expects()``
|
|
|
18 |
* ``shouldAllowMockingMethod()``
|
|
|
19 |
* ``shouldIgnoreMissing()``
|
|
|
20 |
* ``asUndefined()``
|
|
|
21 |
* ``shouldAllowMockingProtectedMethods()``
|
|
|
22 |
* ``makePartial()``
|
|
|
23 |
* ``byDefault()``
|
|
|
24 |
* ``shouldHaveReceived()``
|
|
|
25 |
* ``shouldHaveBeenCalled()``
|
|
|
26 |
* ``shouldNotHaveReceived()``
|
|
|
27 |
* ``shouldNotHaveBeenCalled()``
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
In addition, all mocks utilise a set of added methods and protected properties
|
|
|
31 |
which cannot exist on the class or object being mocked. These are far less
|
|
|
32 |
likely to cause collisions. All properties are prefixed with ``_mockery`` and
|
|
|
33 |
all method names with ``mockery_``.
|