File Manager Lite
Dir:
/home/codewavebd/public_html/vendor/mockery/mockery/docs/reference
Upload
[..]
alternative_should_receive_syntax.rst (2.33 KB)
Edit
Rename
Del
argument_validation.rst (10.49 KB)
Edit
Rename
Del
creating_test_doubles.rst (14.12 KB)
Edit
Rename
Del
demeter_chains.rst (1.6 KB)
Edit
Rename
Del
expectations.rst (15.57 KB)
Edit
Rename
Del
final_methods_classes.rst (1.32 KB)
Edit
Rename
Del
index.rst (421 B)
Edit
Rename
Del
instance_mocking.rst (805 B)
Edit
Rename
Del
magic_methods.rst (687 B)
Edit
Rename
Del
map.rst.inc (550 B)
Edit
Rename
Del
partial_mocks.rst (4.19 KB)
Edit
Rename
Del
pass_by_reference_behaviours.rst (4.22 KB)
Edit
Rename
Del
protected_methods.rst (668 B)
Edit
Rename
Del
public_properties.rst (821 B)
Edit
Rename
Del
public_static_properties.rst (701 B)
Edit
Rename
Del
spies.rst (4.63 KB)
Edit
Rename
Del
Edit: final_methods_classes.rst
.. index:: single: Mocking; Final Classes/Methods Dealing with Final Classes/Methods ================================== One of the primary restrictions of mock objects in PHP, is that mocking classes or methods marked final is hard. The final keyword prevents methods so marked from being replaced in subclasses (subclassing is how mock objects can inherit the type of the class or object being mocked). The simplest solution is to implement an interface in your final class and typehint against / mock this. However this may not be possible in some third party libraries. Mockery does allow creating "proxy mocks" from classes marked final, or from classes with methods marked final. This offers all the usual mock object goodness but the resulting mock will not inherit the class type of the object being mocked, i.e. it will not pass any instanceof comparison. Methods marked as final will be proxied to the original method, i.e., final methods can't be mocked. We can create a proxy mock by passing the instantiated object we wish to mock into ``\Mockery::mock()``, i.e. Mockery will then generate a Proxy to the real object and selectively intercept method calls for the purposes of setting and meeting expectations. See the :ref:`creating-test-doubles-partial-test-doubles` chapter, the subsection about proxied partial test doubles.
Simpan