Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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 sprintf;
13
use PHPUnit\Framework\ExpectationFailedException;
14
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
15
 
16
/**
17
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
18
 *
19
 * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4297
20
 *
21
 * @codeCoverageIgnore
22
 */
23
final class InvokedAtIndex extends InvocationOrder
24
{
25
    /**
26
     * @var int
27
     */
28
    private $sequenceIndex;
29
 
30
    /**
31
     * @var int
32
     */
33
    private $currentIndex = -1;
34
 
35
    /**
36
     * @param int $sequenceIndex
37
     */
38
    public function __construct($sequenceIndex)
39
    {
40
        $this->sequenceIndex = $sequenceIndex;
41
    }
42
 
43
    public function toString(): string
44
    {
45
        return 'invoked at sequence index ' . $this->sequenceIndex;
46
    }
47
 
48
    public function matches(BaseInvocation $invocation): bool
49
    {
50
        $this->currentIndex++;
51
 
52
        return $this->currentIndex == $this->sequenceIndex;
53
    }
54
 
55
    /**
56
     * Verifies that the current expectation is valid. If everything is OK the
57
     * code should just return, if not it must throw an exception.
58
     *
59
     * @throws ExpectationFailedException
60
     */
61
    public function verify(): void
62
    {
63
        if ($this->currentIndex < $this->sequenceIndex) {
64
            throw new ExpectationFailedException(
65
                sprintf(
66
                    'The expected invocation at index %s was never reached.',
67
                    $this->sequenceIndex
68
                )
69
            );
70
        }
71
    }
72
 
73
    protected function invokedDo(BaseInvocation $invocation): void
74
    {
75
    }
76
}