Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
.. index::
2
    single: Mockery; Exceptions
3
 
4
Mockery Exceptions
5
==================
6
 
7
Mockery throws three types of exceptions when it cannot verify a mock object.
8
 
9
#. ``\Mockery\Exception\InvalidCountException``
10
#. ``\Mockery\Exception\InvalidOrderException``
11
#. ``\Mockery\Exception\NoMatchingExpectationException``
12
 
13
You can capture any of these exceptions in a try...catch block to query them
14
for specific information which is also passed along in the exception message
15
but is provided separately from getters should they be useful when logging or
16
reformatting output.
17
 
18
\Mockery\Exception\InvalidCountException
19
----------------------------------------
20
 
21
The exception class is used when a method is called too many (or too few)
22
times and offers the following methods:
23
 
24
* ``getMock()`` - return actual mock object
25
* ``getMockName()`` - return the name of the mock object
26
* ``getMethodName()`` - return the name of the method the failing expectation
27
  is attached to
28
* ``getExpectedCount()`` - return expected calls
29
* ``getExpectedCountComparative()`` - returns a string, e.g. ``<=`` used to
30
  compare to actual count
31
* ``getActualCount()`` - return actual calls made with given argument
32
  constraints
33
 
34
\Mockery\Exception\InvalidOrderException
35
----------------------------------------
36
 
37
The exception class is used when a method is called outside the expected order
38
set using the ``ordered()`` and ``globally()`` expectation modifiers. It
39
offers the following methods:
40
 
41
* ``getMock()`` - return actual mock object
42
* ``getMockName()`` - return the name of the mock object
43
* ``getMethodName()`` - return the name of the method the failing expectation
44
  is attached to
45
* ``getExpectedOrder()`` - returns an integer represented the expected index
46
  for which this call was expected
47
* ``getActualOrder()`` - return the actual index at which this method call
48
  occurred.
49
 
50
\Mockery\Exception\NoMatchingExpectationException
51
-------------------------------------------------
52
 
53
The exception class is used when a method call does not match any known
54
expectation.  All expectations are uniquely identified in a mock object by the
55
method name and the list of expected arguments. You can disable this exception
56
and opt for returning NULL from all unexpected method calls by using the
57
earlier mentioned shouldIgnoreMissing() behaviour modifier. This exception
58
class offers the following methods:
59
 
60
* ``getMock()`` - return actual mock object
61
* ``getMockName()`` - return the name of the mock object
62
* ``getMethodName()`` - return the name of the method the failing expectation
63
  is attached to
64
* ``getActualArguments()`` - return actual arguments used to search for a
65
  matching expectation