| 148 |
lars |
1 |
<?php declare(strict_types=1);
|
|
|
2 |
/*
|
|
|
3 |
* This file is part of PHPUnit.
|
|
|
4 |
*
|
|
|
5 |
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
namespace PHPUnit\Framework\MockObject\Rule;
|
|
|
11 |
|
|
|
12 |
use function count;
|
|
|
13 |
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
|
|
14 |
use PHPUnit\Framework\MockObject\Verifiable;
|
|
|
15 |
use PHPUnit\Framework\SelfDescribing;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
|
|
19 |
*/
|
|
|
20 |
abstract class InvocationOrder implements SelfDescribing, Verifiable
|
|
|
21 |
{
|
|
|
22 |
/**
|
|
|
23 |
* @var BaseInvocation[]
|
|
|
24 |
*/
|
|
|
25 |
private $invocations = [];
|
|
|
26 |
|
|
|
27 |
public function getInvocationCount(): int
|
|
|
28 |
{
|
|
|
29 |
return count($this->invocations);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function hasBeenInvoked(): bool
|
|
|
33 |
{
|
|
|
34 |
return count($this->invocations) > 0;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
final public function invoked(BaseInvocation $invocation)
|
|
|
38 |
{
|
|
|
39 |
$this->invocations[] = $invocation;
|
|
|
40 |
|
|
|
41 |
return $this->invokedDo($invocation);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
abstract public function matches(BaseInvocation $invocation): bool;
|
|
|
45 |
|
|
|
46 |
abstract protected function invokedDo(BaseInvocation $invocation);
|
|
|
47 |
}
|