Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MethodProphecy.php

function MethodProphecy::shouldHave

Checks provided prediction immediately.

Parameters

callable|Prediction\PredictionInterface $prediction:

Return value

$this

Throws

\Prophecy\Exception\InvalidArgumentException

PredictionException

4 calls to MethodProphecy::shouldHave()
MethodProphecy::checkPrediction in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Checks currently registered [with should(...)] prediction.
MethodProphecy::shouldHaveBeenCalled in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Checks call prediction.
MethodProphecy::shouldHaveBeenCalledTimes in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Checks call times prediction.
MethodProphecy::shouldNotHaveBeenCalled in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Checks no calls prediction.

File

vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php, line 420

Class

MethodProphecy
Method prophecy.

Namespace

Prophecy\Prophecy

Code

public function shouldHave($prediction) {
    if (is_callable($prediction)) {
        $prediction = new Prediction\CallbackPrediction($prediction);
    }
    if (!$prediction instanceof Prediction\PredictionInterface) {
        throw new InvalidArgumentException(sprintf('Expected callable or instance of PredictionInterface, but got %s.', gettype($prediction)));
    }
    if (null === $this->promise && !$this->voidReturnType) {
        $this->willReturn();
    }
    $calls = $this->getObjectProphecy()
        ->findProphecyMethodCalls($this->getMethodName(), $this->getArgumentsWildcard());
    try {
        $prediction->check($calls, $this->getObjectProphecy(), $this);
        $this->checkedPredictions[] = $prediction;
    } catch (\Exception $e) {
        $this->checkedPredictions[] = $prediction;
        throw $e;
    }
    return $this;
}
RSS feed
Powered by Drupal