Complex classes like Expectation often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Expectation, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 29 | class Expectation implements ExpectationInterface |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * Mock object to which this expectation belongs |
||
| 33 | * |
||
| 34 | * @var object |
||
| 35 | */ |
||
| 36 | protected $_mock = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Method name |
||
| 40 | * |
||
| 41 | * @var string |
||
| 42 | */ |
||
| 43 | protected $_name = null; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Arguments expected by this expectation |
||
| 47 | * |
||
| 48 | * @var array |
||
| 49 | */ |
||
| 50 | protected $_expectedArgs = array(); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Count validator store |
||
| 54 | * |
||
| 55 | * @var \Mockery\CountValidator\CountValidatorAbstract[] |
||
| 56 | */ |
||
| 57 | protected $_countValidators = array(); |
||
| 58 | |||
| 59 | /** |
||
| 60 | * The count validator class to use |
||
| 61 | * |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | protected $_countValidatorClass = 'Mockery\CountValidator\Exact'; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Actual count of calls to this expectation |
||
| 68 | * |
||
| 69 | * @var int |
||
| 70 | */ |
||
| 71 | protected $_actualCount = 0; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Value to return from this expectation |
||
| 75 | * |
||
| 76 | * @var mixed |
||
| 77 | */ |
||
| 78 | protected $_returnValue = null; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Array of return values as a queue for multiple return sequence |
||
| 82 | * |
||
| 83 | * @var array |
||
| 84 | */ |
||
| 85 | protected $_returnQueue = array(); |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Array of closures executed with given arguments to generate a result |
||
| 89 | * to be returned |
||
| 90 | * |
||
| 91 | * @var array |
||
| 92 | */ |
||
| 93 | protected $_closureQueue = array(); |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Array of values to be set when this expectation matches |
||
| 97 | * |
||
| 98 | * @var array |
||
| 99 | */ |
||
| 100 | protected $_setQueue = array(); |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Integer representing the call order of this expectation |
||
| 104 | * |
||
| 105 | * @var int |
||
| 106 | */ |
||
| 107 | protected $_orderNumber = null; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Integer representing the call order of this expectation on a global basis |
||
| 111 | * |
||
| 112 | * @var int |
||
| 113 | */ |
||
| 114 | protected $_globalOrderNumber = null; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Flag indicating that an exception is expected to be throw (not returned) |
||
| 118 | * |
||
| 119 | * @var bool |
||
| 120 | */ |
||
| 121 | protected $_throw = false; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Flag indicating whether the order of calling is determined locally or |
||
| 125 | * globally |
||
| 126 | * |
||
| 127 | * @var bool |
||
| 128 | */ |
||
| 129 | protected $_globally = false; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Flag indicating if the return value should be obtained from the original |
||
| 133 | * class method instead of returning predefined values from the return queue |
||
| 134 | * |
||
| 135 | * @var bool |
||
| 136 | */ |
||
| 137 | protected $_passthru = false; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Constructor |
||
| 141 | * |
||
| 142 | * @param \Mockery\MockInterface $mock |
||
| 143 | * @param string $name |
||
| 144 | */ |
||
| 145 | 344 | public function __construct(\Mockery\MockInterface $mock, $name) |
|
| 146 | { |
||
| 147 | 344 | $this->_mock = $mock; |
|
| 148 | 344 | $this->_name = $name; |
|
| 149 | 344 | $this->withAnyArgs(); |
|
| 150 | 344 | } |
|
| 151 | |||
| 152 | /** |
||
| 153 | * Return a string with the method name and arguments formatted |
||
| 154 | * |
||
| 155 | * @param string $name Name of the expected method |
||
| 156 | * @param array $args List of arguments to the method |
||
| 157 | * @return string |
||
| 158 | */ |
||
| 159 | 45 | public function __toString() |
|
| 160 | { |
||
| 161 | 45 | return \Mockery::formatArgs($this->_name, $this->_expectedArgs); |
|
| 162 | } |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Verify the current call, i.e. that the given arguments match those |
||
| 166 | * of this expectation |
||
| 167 | * |
||
| 168 | * @param array $args |
||
| 169 | * @return mixed |
||
| 170 | */ |
||
| 171 | 273 | public function verifyCall(array $args) |
|
| 172 | { |
||
| 173 | 273 | $this->validateOrder(); |
|
| 174 | 273 | $this->_actualCount++; |
|
| 175 | 273 | if (true === $this->_passthru) { |
|
| 176 | 3 | return $this->_mock->mockery_callSubjectMethod($this->_name, $args); |
|
| 177 | } |
||
| 178 | |||
| 179 | 271 | $return = $this->_getReturnValue($args); |
|
| 180 | 271 | $this->throwAsNecessary($return); |
|
| 181 | 264 | $this->_setValues(); |
|
| 182 | |||
| 183 | 264 | return $return; |
|
| 184 | } |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Throws an exception if the expectation has been configured to do so |
||
| 188 | * |
||
| 189 | * @throws \Exception|\Throwable |
||
| 190 | * @return void |
||
| 191 | */ |
||
| 192 | 271 | private function throwAsNecessary($return) |
|
| 193 | { |
||
| 194 | 271 | if (!$this->_throw) { |
|
| 195 | 264 | return; |
|
| 196 | } |
||
| 197 | |||
| 198 | 8 | $type = version_compare(PHP_VERSION, '7.0.0') >= 0 |
|
| 199 | 8 | ? "\Throwable" |
|
| 200 | 8 | : "\Exception"; |
|
| 201 | |||
| 202 | 8 | if ($return instanceof $type) { |
|
| 203 | 8 | throw $return; |
|
| 204 | } |
||
| 205 | |||
| 206 | return; |
||
|
|
|||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Sets public properties with queued values to the mock object |
||
| 211 | * |
||
| 212 | * @param array $args |
||
| 213 | * @return mixed |
||
| 214 | */ |
||
| 215 | 264 | protected function _setValues() |
|
| 216 | { |
||
| 217 | 264 | foreach ($this->_setQueue as $name => &$values) { |
|
| 218 | 8 | if (count($values) > 0) { |
|
| 219 | 8 | $value = array_shift($values); |
|
| 220 | 8 | $this->_mock->{$name} = $value; |
|
| 221 | } |
||
| 222 | } |
||
| 223 | 264 | } |
|
| 224 | |||
| 225 | /** |
||
| 226 | * Fetch the return value for the matching args |
||
| 227 | * |
||
| 228 | * @param array $args |
||
| 229 | * @return mixed |
||
| 230 | */ |
||
| 231 | 271 | protected function _getReturnValue(array $args) |
|
| 232 | { |
||
| 233 | 271 | if (count($this->_closureQueue) > 1) { |
|
| 234 | return call_user_func_array(array_shift($this->_closureQueue), $args); |
||
| 235 | 271 | } elseif (count($this->_closureQueue) > 0) { |
|
| 236 | 1 | return call_user_func_array(current($this->_closureQueue), $args); |
|
| 237 | 270 | } elseif (count($this->_returnQueue) > 1) { |
|
| 238 | 5 | return array_shift($this->_returnQueue); |
|
| 239 | 269 | } elseif (count($this->_returnQueue) > 0) { |
|
| 240 | 122 | return current($this->_returnQueue); |
|
| 241 | } |
||
| 242 | |||
| 243 | 148 | return $this->_mock->mockery_returnValueForMethod($this->_name); |
|
| 244 | } |
||
| 245 | |||
| 246 | /** |
||
| 247 | * Checks if this expectation is eligible for additional calls |
||
| 248 | * |
||
| 249 | * @return bool |
||
| 250 | */ |
||
| 251 | 310 | public function isEligible() |
|
| 252 | { |
||
| 253 | 310 | foreach ($this->_countValidators as $validator) { |
|
| 254 | 140 | if (!$validator->isEligible($this->_actualCount)) { |
|
| 255 | 140 | return false; |
|
| 256 | } |
||
| 257 | } |
||
| 258 | 307 | return true; |
|
| 259 | } |
||
| 260 | |||
| 261 | 270 | public function isExpected() |
|
| 262 | { |
||
| 263 | 270 | foreach ($this->_countValidators as $validator) { |
|
| 264 | 137 | if ($validator->isEligible($this->_actualCount)) { |
|
| 265 | 137 | return true; |
|
| 266 | } |
||
| 267 | } |
||
| 268 | 185 | return false; |
|
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Check if there is a constraint on call count |
||
| 273 | * |
||
| 274 | * @return bool |
||
| 275 | */ |
||
| 276 | public function isCallCountConstrained() |
||
| 277 | { |
||
| 278 | return (count($this->_countValidators) > 0); |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * Verify call order |
||
| 283 | * |
||
| 284 | * @return void |
||
| 285 | */ |
||
| 286 | 273 | public function validateOrder() |
|
| 287 | { |
||
| 288 | 273 | if ($this->_orderNumber) { |
|
| 289 | 15 | $this->_mock->mockery_validateOrder((string) $this, $this->_orderNumber, $this->_mock); |
|
| 290 | } |
||
| 291 | 273 | if ($this->_globalOrderNumber) { |
|
| 292 | 1 | $this->_mock->mockery_getContainer() |
|
| 293 | 1 | ->mockery_validateOrder((string) $this, $this->_globalOrderNumber, $this->_mock); |
|
| 294 | } |
||
| 295 | 273 | } |
|
| 296 | |||
| 297 | /** |
||
| 298 | * Verify this expectation |
||
| 299 | * |
||
| 300 | * @return bool |
||
| 301 | */ |
||
| 302 | 151 | public function verify() |
|
| 303 | { |
||
| 304 | 151 | foreach ($this->_countValidators as $validator) { |
|
| 305 | 122 | $validator->validate($this->_actualCount); |
|
| 306 | } |
||
| 307 | 133 | } |
|
| 308 | |||
| 309 | /** |
||
| 310 | * Check if the registered expectation is an ArgumentListMatcher |
||
| 311 | * @return bool |
||
| 312 | */ |
||
| 313 | 317 | private function isArgumentListMatcher() |
|
| 314 | { |
||
| 315 | 317 | return (count($this->_expectedArgs) === 1 && ($this->_expectedArgs[0] instanceof ArgumentListMatcher)); |
|
| 316 | } |
||
| 317 | |||
| 318 | /** |
||
| 319 | * Check if passed arguments match an argument expectation |
||
| 320 | * |
||
| 321 | * @param array $args |
||
| 322 | * @return bool |
||
| 323 | */ |
||
| 324 | 317 | public function matchArgs(array $args) |
|
| 325 | { |
||
| 326 | 317 | if ($this->isArgumentListMatcher()) { |
|
| 327 | 218 | return $this->_matchArg($this->_expectedArgs[0], $args); |
|
| 328 | } |
||
| 329 | 105 | $argCount = count($args); |
|
| 330 | 105 | if ($argCount !== count($this->_expectedArgs)) { |
|
| 331 | 5 | return false; |
|
| 332 | } |
||
| 333 | 102 | for ($i=0; $i<$argCount; $i++) { |
|
| 334 | 102 | $param =& $args[$i]; |
|
| 335 | 102 | if (!$this->_matchArg($this->_expectedArgs[$i], $param)) { |
|
| 336 | 45 | return false; |
|
| 337 | } |
||
| 338 | } |
||
| 339 | |||
| 340 | 66 | return true; |
|
| 341 | } |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Check if passed argument matches an argument expectation |
||
| 345 | * |
||
| 346 | * @param mixed $expected |
||
| 347 | * @param mixed &$actual |
||
| 348 | * @return bool |
||
| 349 | */ |
||
| 350 | 314 | protected function _matchArg($expected, &$actual) |
|
| 351 | { |
||
| 352 | 314 | if ($expected === $actual) { |
|
| 353 | 31 | return true; |
|
| 354 | } |
||
| 355 | 299 | if (!is_object($expected) && !is_object($actual) && $expected == $actual) { |
|
| 356 | return true; |
||
| 357 | } |
||
| 358 | 299 | if (is_string($expected) && !is_array($actual) && !is_object($actual)) { |
|
| 359 | # push/pop an error handler here to to make sure no error/exception thrown if $expected is not a regex |
||
| 360 | 6 | set_error_handler(function () { |
|
| 361 | 6 | }); |
|
| 362 | 6 | $result = preg_match($expected, (string) $actual); |
|
| 363 | 6 | restore_error_handler(); |
|
| 364 | |||
| 365 | 6 | if ($result) { |
|
| 366 | 3 | return true; |
|
| 367 | } |
||
| 368 | } |
||
| 369 | 298 | if (is_string($expected) && is_object($actual)) { |
|
| 370 | 1 | $result = $actual instanceof $expected; |
|
| 371 | 1 | if ($result) { |
|
| 372 | 1 | return true; |
|
| 373 | } |
||
| 374 | } |
||
| 375 | 297 | if ($expected instanceof \Mockery\Matcher\MatcherAbstract) { |
|
| 376 | 278 | return $expected->match($actual); |
|
| 377 | } |
||
| 378 | 21 | if ($expected instanceof \Hamcrest\Matcher || $expected instanceof \Hamcrest_Matcher) { |
|
| 379 | 3 | return $expected->matches($actual); |
|
| 380 | } |
||
| 381 | 18 | return false; |
|
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Expected argument setter for the expectation |
||
| 386 | * |
||
| 387 | * @param mixed[] ... |
||
| 388 | * @return self |
||
| 389 | */ |
||
| 390 | 130 | public function with(...$args) |
|
| 391 | { |
||
| 392 | 130 | return $this->withArgs($args); |
|
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * Expected arguments for the expectation passed as an array |
||
| 397 | * |
||
| 398 | * @param array $arguments |
||
| 399 | * @return Expectation |
||
| 400 | */ |
||
| 401 | 140 | private function withArgsInArray(array $arguments) |
|
| 402 | { |
||
| 403 | 140 | if (empty($arguments)) { |
|
| 404 | 3 | return $this->withNoArgs(); |
|
| 405 | } |
||
| 406 | 137 | $this->_expectedArgs = $arguments; |
|
| 407 | 137 | return $this; |
|
| 408 | } |
||
| 409 | |||
| 410 | /** |
||
| 411 | * Expected arguments have to be matched by the given closure. |
||
| 412 | * |
||
| 413 | * @param Closure $closure |
||
| 414 | * @return Expectation |
||
| 415 | */ |
||
| 416 | 6 | private function withArgsMatchedByClosure(Closure $closure) |
|
| 417 | { |
||
| 418 | 6 | $this->_expectedArgs = [new MultiArgumentClosure($closure)]; |
|
| 419 | 6 | return $this; |
|
| 420 | } |
||
| 421 | |||
| 422 | /** |
||
| 423 | * Expected arguments for the expectation passed as an array or a closure that matches each passed argument on |
||
| 424 | * each function call. |
||
| 425 | * |
||
| 426 | * @param array|Closure $argsOrClosure |
||
| 427 | * @return Expectation |
||
| 428 | */ |
||
| 429 | 147 | public function withArgs($argsOrClosure) |
|
| 430 | { |
||
| 431 | 147 | if (is_array($argsOrClosure)) { |
|
| 432 | 140 | $this->withArgsInArray($argsOrClosure); |
|
| 433 | } elseif ($argsOrClosure instanceof Closure) { |
||
| 434 | 6 | $this->withArgsMatchedByClosure($argsOrClosure); |
|
| 435 | } else { |
||
| 436 | 1 | throw new \InvalidArgumentException(sprintf('Call to %s with an invalid argument (%s), only array and '. |
|
| 437 | 1 | 'closure are allowed', __METHOD__, $argsOrClosure)); |
|
| 438 | } |
||
| 439 | 146 | return $this; |
|
| 440 | } |
||
| 441 | |||
| 442 | /** |
||
| 443 | * Set with() as no arguments expected |
||
| 444 | * |
||
| 445 | * @return Expectation |
||
| 446 | */ |
||
| 447 | 7 | public function withNoArgs() |
|
| 448 | { |
||
| 449 | 7 | $this->_expectedArgs = [new NoArgs()]; |
|
| 450 | 7 | return $this; |
|
| 451 | } |
||
| 452 | |||
| 453 | /** |
||
| 454 | * Set expectation that any arguments are acceptable |
||
| 455 | * |
||
| 456 | * @return Expectation |
||
| 457 | */ |
||
| 458 | 344 | public function withAnyArgs() |
|
| 459 | { |
||
| 460 | 344 | $this->_expectedArgs = [new AnyArgs()]; |
|
| 461 | 344 | return $this; |
|
| 462 | } |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Set a return value, or sequential queue of return values |
||
| 466 | * |
||
| 467 | * @param mixed[] ... |
||
| 468 | * @return self |
||
| 469 | */ |
||
| 470 | 135 | public function andReturn(...$args) |
|
| 471 | { |
||
| 472 | 135 | $this->_returnQueue = $args; |
|
| 473 | 135 | return $this; |
|
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Set a return value, or sequential queue of return values |
||
| 478 | * |
||
| 479 | * @param mixed[] ... |
||
| 480 | * @return self |
||
| 481 | */ |
||
| 482 | public function andReturns(...$args) |
||
| 483 | { |
||
| 484 | return call_user_func_array([$this, 'andReturn'], $args); |
||
| 485 | } |
||
| 486 | |||
| 487 | /** |
||
| 488 | * Return this mock, like a fluent interface |
||
| 489 | * |
||
| 490 | * @return Expectation |
||
| 491 | */ |
||
| 492 | 1 | public function andReturnSelf() |
|
| 496 | |||
| 497 | /** |
||
| 498 | * Set a sequential queue of return values with an array |
||
| 499 | * |
||
| 500 | * @param array $values |
||
| 501 | * @return Expectation |
||
| 502 | */ |
||
| 503 | 2 | public function andReturnValues(array $values) |
|
| 508 | |||
| 509 | /** |
||
| 510 | * Set a closure or sequence of closures with which to generate return |
||
| 511 | * values. The arguments passed to the expected method are passed to the |
||
| 512 | * closures as parameters. |
||
| 513 | * |
||
| 514 | * @param callable[] $args |
||
| 515 | * @return self |
||
| 516 | */ |
||
| 517 | 1 | public function andReturnUsing(...$args) |
|
| 518 | { |
||
| 519 | 1 | $this->_closureQueue = $args; |
|
| 520 | 1 | return $this; |
|
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Return a self-returning black hole object. |
||
| 525 | * |
||
| 526 | * @return Expectation |
||
| 527 | */ |
||
| 528 | 1 | public function andReturnUndefined() |
|
| 533 | |||
| 534 | /** |
||
| 535 | * Return null. This is merely a language construct for Mock describing. |
||
| 536 | * |
||
| 537 | * @return Expectation |
||
| 538 | */ |
||
| 539 | 4 | public function andReturnNull() |
|
| 543 | |||
| 544 | 1 | public function andReturnFalse() |
|
| 548 | |||
| 549 | 1 | public function andReturnTrue() |
|
| 553 | |||
| 554 | /** |
||
| 555 | * Set Exception class and arguments to that class to be thrown |
||
| 556 | * |
||
| 557 | * @param string|\Exception $exception |
||
| 558 | * @param string $message |
||
| 559 | * @param int $code |
||
| 560 | * @param \Exception $previous |
||
| 561 | * @return Expectation |
||
| 562 | */ |
||
| 563 | 7 | public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null) |
|
| 573 | |||
| 574 | /** |
||
| 575 | * Set Exception classes to be thrown |
||
| 576 | * |
||
| 577 | * @param array $exceptions |
||
| 578 | * @return Expectation |
||
| 579 | */ |
||
| 580 | 2 | public function andThrowExceptions(array $exceptions) |
|
| 590 | |||
| 591 | /** |
||
| 592 | * Register values to be set to a public property each time this expectation occurs |
||
| 593 | * |
||
| 594 | * @param string $name |
||
| 595 | * @param array $values |
||
| 596 | * @return self |
||
| 597 | */ |
||
| 598 | 8 | public function andSet($name, ...$values) |
|
| 599 | { |
||
| 600 | 8 | $this->_setQueue[$name] = $values; |
|
| 601 | 8 | return $this; |
|
| 602 | } |
||
| 603 | |||
| 604 | /** |
||
| 605 | * Alias to andSet(). Allows the natural English construct |
||
| 606 | * - set('foo', 'bar')->andReturn('bar') |
||
| 607 | * |
||
| 608 | * @param string $name |
||
| 609 | * @param mixed $value |
||
| 610 | * @return Expectation |
||
| 611 | */ |
||
| 612 | 3 | public function set($name, $value) |
|
| 613 | { |
||
| 614 | 3 | return call_user_func_array(array($this, 'andSet'), func_get_args()); |
|
| 616 | |||
| 617 | /** |
||
| 618 | * Indicates this expectation should occur zero or more times |
||
| 619 | * |
||
| 620 | * @return Expectation |
||
| 621 | */ |
||
| 622 | 2 | public function zeroOrMoreTimes() |
|
| 626 | |||
| 627 | /** |
||
| 628 | * Indicates the number of times this expectation should occur |
||
| 629 | * |
||
| 630 | * @param int $limit |
||
| 631 | * @throws \InvalidArgumentException |
||
| 632 | * @return self |
||
| 633 | */ |
||
| 634 | 160 | public function times($limit = null) |
|
| 646 | |||
| 647 | /** |
||
| 648 | * Indicates that this expectation is never expected to be called |
||
| 649 | * |
||
| 650 | * @return Expectation |
||
| 651 | */ |
||
| 652 | 38 | public function never() |
|
| 656 | |||
| 657 | /** |
||
| 658 | * Indicates that this expectation is expected exactly once |
||
| 659 | * |
||
| 660 | * @return Expectation |
||
| 661 | */ |
||
| 662 | 110 | public function once() |
|
| 666 | |||
| 667 | /** |
||
| 668 | * Indicates that this expectation is expected exactly twice |
||
| 669 | * |
||
| 670 | * @return Expectation |
||
| 671 | */ |
||
| 672 | 19 | public function twice() |
|
| 676 | |||
| 677 | /** |
||
| 678 | * Sets next count validator to the AtLeast instance |
||
| 679 | * |
||
| 680 | * @return Expectation |
||
| 681 | */ |
||
| 682 | 15 | public function atLeast() |
|
| 687 | |||
| 688 | /** |
||
| 689 | * Sets next count validator to the AtMost instance |
||
| 690 | * |
||
| 691 | * @return Expectation |
||
| 692 | */ |
||
| 693 | 7 | public function atMost() |
|
| 698 | |||
| 699 | /** |
||
| 700 | * Shorthand for setting minimum and maximum constraints on call counts |
||
| 701 | * |
||
| 702 | * @param int $minimum |
||
| 703 | * @param int $maximum |
||
| 704 | */ |
||
| 705 | public function between($minimum, $maximum) |
||
| 709 | |||
| 710 | /** |
||
| 711 | * Indicates that this expectation must be called in a specific given order |
||
| 712 | * |
||
| 713 | * @param string $group Name of the ordered group |
||
| 714 | * @return Expectation |
||
| 715 | */ |
||
| 716 | 17 | public function ordered($group = null) |
|
| 726 | |||
| 727 | /** |
||
| 728 | * Indicates call order should apply globally |
||
| 729 | * |
||
| 730 | * @return Expectation |
||
| 731 | */ |
||
| 732 | 1 | public function globally() |
|
| 737 | |||
| 738 | /** |
||
| 739 | * Setup the ordering tracking on the mock or mock container |
||
| 740 | * |
||
| 741 | * @param string $group |
||
| 742 | * @param object $ordering |
||
| 743 | * @return int |
||
| 744 | */ |
||
| 745 | 17 | protected function _defineOrdered($group, $ordering) |
|
| 758 | |||
| 759 | /** |
||
| 760 | * Return order number |
||
| 761 | * |
||
| 762 | * @return int |
||
| 763 | */ |
||
| 764 | 284 | public function getOrderNumber() |
|
| 768 | |||
| 769 | /** |
||
| 770 | * Mark this expectation as being a default |
||
| 771 | * |
||
| 772 | * @return Expectation |
||
| 773 | */ |
||
| 774 | 35 | public function byDefault() |
|
| 782 | |||
| 783 | /** |
||
| 784 | * Return the parent mock of the expectation |
||
| 785 | * |
||
| 786 | * @return \Mockery\MockInterface |
||
| 787 | */ |
||
| 788 | 29 | public function getMock() |
|
| 792 | |||
| 793 | /** |
||
| 794 | * Flag this expectation as calling the original class method with the |
||
| 795 | * any provided arguments instead of using a return value queue. |
||
| 796 | * |
||
| 797 | * @return Expectation |
||
| 798 | */ |
||
| 799 | 3 | public function passthru() |
|
| 810 | |||
| 811 | /** |
||
| 812 | * Cloning logic |
||
| 813 | * |
||
| 814 | */ |
||
| 815 | 10 | public function __clone() |
|
| 824 | |||
| 825 | 7 | public function getName() |
|
| 829 | } |
||
| 830 |