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; Protected Methods
3
 
4
Mocking Protected Methods
5
=========================
6
 
7
By default, Mockery does not allow mocking protected methods. We do not recommend
8
mocking protected methods, but there are cases when there is no other solution.
9
 
10
For those cases we have the ``shouldAllowMockingProtectedMethods()`` method. It
11
instructs Mockery to specifically allow mocking of protected methods, for that
12
one class only:
13
 
14
.. code-block:: php
15
 
16
    class MyClass
17
    {
18
        protected function foo()
19
        {
20
        }
21
    }
22
 
23
    $mock = \Mockery::mock('MyClass')
24
        ->shouldAllowMockingProtectedMethods();
25
    $mock->shouldReceive('foo');
26