| 148 |
lars |
1 |
.. index::
|
|
|
2 |
single: Mocking; Public Properties
|
|
|
3 |
|
|
|
4 |
Mocking Public Properties
|
|
|
5 |
=========================
|
|
|
6 |
|
|
|
7 |
Mockery allows us to mock properties in several ways. One way is that we can set
|
|
|
8 |
a public property and its value on any mock object. The second is that we can
|
|
|
9 |
use the expectation methods ``set()`` and ``andSet()`` to set property values if
|
|
|
10 |
that expectation is ever met.
|
|
|
11 |
|
|
|
12 |
You can read more about :ref:`expectations-setting-public-properties`.
|
|
|
13 |
|
|
|
14 |
.. note::
|
|
|
15 |
|
|
|
16 |
In general, Mockery does not support mocking any magic methods since these
|
|
|
17 |
are generally not considered a public API (and besides it is a bit difficult
|
|
|
18 |
to differentiate them when you badly need them for mocking!). So please mock
|
|
|
19 |
virtual properties (those relying on ``__get()`` and ``__set()``) as if they
|
|
|
20 |
were actually declared on the class.
|