All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
27 lines
668 B
ReStructuredText
27 lines
668 B
ReStructuredText
.. index::
|
|
single: Mocking; Protected Methods
|
|
|
|
Mocking Protected Methods
|
|
=========================
|
|
|
|
By default, Mockery does not allow mocking protected methods. We do not recommend
|
|
mocking protected methods, but there are cases when there is no other solution.
|
|
|
|
For those cases we have the ``shouldAllowMockingProtectedMethods()`` method. It
|
|
instructs Mockery to specifically allow mocking of protected methods, for that
|
|
one class only:
|
|
|
|
.. code-block:: php
|
|
|
|
class MyClass
|
|
{
|
|
protected function foo()
|
|
{
|
|
}
|
|
}
|
|
|
|
$mock = \Mockery::mock('MyClass')
|
|
->shouldAllowMockingProtectedMethods();
|
|
$mock->shouldReceive('foo');
|
|
|