Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 216.73.216.153
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
3 /
mockery /
mockery /
docs /
reference /
Delete
Unzip
Name
Size
Permission
Date
Action
alternative_should_receive_syntax.rst
2.33
KB
-rw-r--r--
2018-10-02 09:00
argument_validation.rst
9.83
KB
-rw-r--r--
2018-10-02 09:00
creating_test_doubles.rst
13.78
KB
-rw-r--r--
2018-10-02 09:00
demeter_chains.rst
1.6
KB
-rw-r--r--
2018-10-02 09:00
expectations.rst
13.41
KB
-rw-r--r--
2018-10-02 09:00
final_methods_classes.rst
1.29
KB
-rw-r--r--
2018-10-02 09:00
index.rst
400
B
-rw-r--r--
2018-10-02 09:00
instance_mocking.rst
805
B
-rw-r--r--
2018-10-02 09:00
magic_methods.rst
687
B
-rw-r--r--
2018-10-02 09:00
map.rst.inc
550
B
-rw-r--r--
2018-10-02 09:00
partial_mocks.rst
4.19
KB
-rw-r--r--
2018-10-02 09:00
pass_by_reference_behaviours.rst
4.22
KB
-rw-r--r--
2018-10-02 09:00
phpunit_integration.rst
4.89
KB
-rw-r--r--
2018-10-02 09:00
protected_methods.rst
668
B
-rw-r--r--
2018-10-02 09:00
public_properties.rst
821
B
-rw-r--r--
2018-10-02 09:00
public_static_properties.rst
701
B
-rw-r--r--
2018-10-02 09:00
spies.rst
4.63
KB
-rw-r--r--
2018-10-02 09:00
Save
Rename
.. index:: single: Alternative shouldReceive Syntax Alternative shouldReceive Syntax ================================ As of Mockery 1.0.0, we support calling methods as we would call any PHP method, and not as string arguments to Mockery ``should*`` methods. The two Mockery methods that enable this are ``allows()`` and ``expects()``. Allows ------ We use ``allows()`` when we create stubs for methods that return a predefined return value, but for these method stubs we don't care how many times, or if at all, were they called. .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->allows([ 'name_of_method_1' => 'return value', 'name_of_method_2' => 'return value', ]); This is equivalent with the following ``shouldReceive`` syntax: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->shouldReceive([ 'name_of_method_1' => 'return value', 'name_of_method_2' => 'return value', ]); Note that with this format, we also tell Mockery that we don't care about the arguments to the stubbed methods. If we do care about the arguments, we would do it like so: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->allows() ->name_of_method_1($arg1) ->andReturn('return value'); This is equivalent with the following ``shouldReceive`` syntax: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->shouldReceive('name_of_method_1') ->with($arg1) ->andReturn('return value'); Expects ------- We use ``expects()`` when we want to verify that a particular method was called: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->expects() ->name_of_method_1($arg1) ->andReturn('return value'); This is equivalent with the following ``shouldReceive`` syntax: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->shouldReceive('name_of_method_1') ->once() ->with($arg1) ->andReturn('return value'); By default ``expects()`` sets up an expectation that the method should be called once and once only. If we expect more than one call to the method, we can change that expectation: .. code-block:: php $mock = \Mockery::mock('MyClass'); $mock->expects() ->name_of_method_1($arg1) ->twice() ->andReturn('return value');