1 | <?php |
||
23 | class ExpectationDirector |
||
24 | { |
||
25 | /** |
||
26 | * Method name the director is directing |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $_name = null; |
||
31 | |||
32 | /** |
||
33 | * Mock object the director is attached to |
||
34 | * |
||
35 | * @var \Mockery\MockInterface |
||
36 | */ |
||
37 | protected $_mock = null; |
||
38 | |||
39 | /** |
||
40 | * Stores an array of all expectations for this mock |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $_expectations = array(); |
||
45 | |||
46 | /** |
||
47 | * The expected order of next call |
||
48 | * |
||
49 | * @var int |
||
50 | */ |
||
51 | protected $_expectedOrder = null; |
||
52 | |||
53 | /** |
||
54 | * Stores an array of all default expectations for this mock |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $_defaults = array(); |
||
59 | |||
60 | /** |
||
61 | * Constructor |
||
62 | * |
||
63 | * @param string $name |
||
64 | * @param \Mockery\MockInterface $mock |
||
65 | */ |
||
66 | 302 | public function __construct($name, \Mockery\MockInterface $mock) |
|
71 | |||
72 | /** |
||
73 | * Add a new expectation to the director |
||
74 | * |
||
75 | * @param \Mockery\Expectation $expectation |
||
76 | */ |
||
77 | 302 | public function addExpectation(\Mockery\Expectation $expectation) |
|
81 | |||
82 | /** |
||
83 | * Handle a method call being directed by this instance |
||
84 | * |
||
85 | * @param array $args |
||
86 | * @return mixed |
||
87 | */ |
||
88 | 275 | public function call(array $args) |
|
108 | |||
109 | /** |
||
110 | * Verify all expectations of the director |
||
111 | * |
||
112 | * @throws \Mockery\CountValidator\Exception |
||
113 | * @return void |
||
114 | */ |
||
115 | 140 | public function verify() |
|
127 | |||
128 | /** |
||
129 | * Attempt to locate an expectation matching the provided args |
||
130 | * |
||
131 | * @param array $args |
||
132 | * @return mixed |
||
133 | */ |
||
134 | 275 | public function findExpectation(array $args) |
|
142 | |||
143 | /** |
||
144 | * Make the given expectation a default for all others assuming it was |
||
145 | * correctly created last |
||
146 | * |
||
147 | * @param \Mockery\Expectation |
||
148 | */ |
||
149 | 27 | public function makeExpectationDefault(\Mockery\Expectation $expectation) |
|
161 | |||
162 | /** |
||
163 | * Search current array of expectations for a match |
||
164 | * |
||
165 | * @param array $expectations |
||
166 | * @param array $args |
||
167 | * @return mixed |
||
168 | */ |
||
169 | 275 | protected function _findExpectationIn(array $expectations, array $args) |
|
182 | |||
183 | /** |
||
184 | * Return all expectations assigned to this director |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 26 | public function getExpectations() |
|
192 | |||
193 | /** |
||
194 | * Return all expectations assigned to this director |
||
195 | * |
||
196 | * @return array |
||
197 | */ |
||
198 | 6 | public function getDefaultExpectations() |
|
199 | { |
||
200 | 6 | return $this->_defaults; |
|
201 | } |
||
202 | |||
203 | /** |
||
204 | * Return the number of expectations assigned to this director. |
||
205 | * |
||
206 | * @return int |
||
207 | */ |
||
208 | 21 | public function getExpectationCount() |
|
212 | } |
||
213 |