Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
.. index::
2
    single: Mocking; Instance
3
 
4
Instance Mocking
5
================
6
 
7
Instance mocking means that a statement like:
8
 
9
.. code-block:: php
10
 
11
    $obj = new \MyNamespace\Foo;
12
 
13
...will actually generate a mock object. This is done by replacing the real
14
class with an instance mock (similar to an alias mock), as with mocking public
15
methods. The alias will import its expectations from the original mock of
16
that type (note that the original is never verified and should be ignored
17
after its expectations are setup). This lets you intercept instantiation where
18
you can't simply inject a replacement object.
19
 
20
As before, this does not prevent a require statement from including the real
21
class and triggering a fatal PHP error. It's intended for use where
22
autoloading is the primary class loading mechanism.