class InvokedAtLeastCount
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@internal This class is not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Framework\MockObject\Rule\InvocationOrder implements \PHPUnit\Framework\SelfDescribing
- class \PHPUnit\Framework\MockObject\Rule\InvokedAtLeastCount extends \PHPUnit\Framework\MockObject\Rule\InvocationOrder
Expanded class hierarchy of InvokedAtLeastCount
2 files declare their use of InvokedAtLeastCount
- Functions.php in vendor/
phpunit/ phpunit/ src/ Framework/ Assert/ Functions.php - TestCase.php in vendor/
phpunit/ phpunit/ src/ Framework/ TestCase.php
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ MockObject/ Runtime/ Rule/ InvokedAtLeastCount.php, line 21
Namespace
PHPUnit\Framework\MockObject\RuleView source
final class InvokedAtLeastCount extends InvocationOrder {
private readonly int $requiredInvocations;
public function __construct(int $requiredInvocations) {
$this->requiredInvocations = $requiredInvocations;
}
public function toString() : string {
return sprintf('invoked at least %d time%s', $this->requiredInvocations, $this->requiredInvocations !== 1 ? 's' : '');
}
/**
* Verifies that the current expectation is valid. If everything is OK the
* code should just return, if not it must throw an exception.
*
* @throws ExpectationFailedException
*/
public function verify() : void {
$actualInvocations = $this->numberOfInvocations();
if ($actualInvocations < $this->requiredInvocations) {
throw new ExpectationFailedException(sprintf('Expected invocation at least %d time%s but it occurred %d time%s.', $this->requiredInvocations, $this->requiredInvocations !== 1 ? 's' : '', $actualInvocations, $actualInvocations !== 1 ? 's' : ''));
}
}
public function matches(BaseInvocation $invocation) : bool {
return true;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
InvocationOrder::$invocations | private | property | @psalm-var list<BaseInvocation> | ||
InvocationOrder::hasBeenInvoked | public | function | |||
InvocationOrder::invoked | final public | function | |||
InvocationOrder::invokedDo | protected | function | 1 | ||
InvocationOrder::numberOfInvocations | public | function | |||
InvokedAtLeastCount::$requiredInvocations | private | property | |||
InvokedAtLeastCount::matches | public | function | Overrides InvocationOrder::matches | ||
InvokedAtLeastCount::toString | public | function | Returns a string representation of the object. | Overrides SelfDescribing::toString | |
InvokedAtLeastCount::verify | public | function | Verifies that the current expectation is valid. If everything is OK the code should just return, if not it must throw an exception. |
Overrides InvocationOrder::verify | |
InvokedAtLeastCount::__construct | public | function |