You are here

public function CallPrediction::check in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Prediction/CallPrediction.php \Prophecy\Prediction\CallPrediction::check()

Tests that there was at least one call.

Parameters

Call[] $calls:

ObjectProphecy $object:

MethodProphecy $method:

Throws

\Prophecy\Exception\Prediction\NoCallsException

Overrides PredictionInterface::check

File

vendor/phpspec/prophecy/src/Prophecy/Prediction/CallPrediction.php, line 50

Class

CallPrediction
Call prediction.

Namespace

Prophecy\Prediction

Code

public function check(array $calls, ObjectProphecy $object, MethodProphecy $method) {
  if (count($calls)) {
    return;
  }
  $methodCalls = $object
    ->findProphecyMethodCalls($method
    ->getMethodName(), new ArgumentsWildcard(array(
    new AnyValuesToken(),
  )));
  if (count($methodCalls)) {
    throw new NoCallsException(sprintf("No calls have been made that match:\n" . "  %s->%s(%s)\n" . "but expected at least one.\n" . "Recorded `%s(...)` calls:\n%s", get_class($object
      ->reveal()), $method
      ->getMethodName(), $method
      ->getArgumentsWildcard(), $method
      ->getMethodName(), $this->util
      ->stringifyCalls($methodCalls)), $method);
  }
  throw new NoCallsException(sprintf("No calls have been made that match:\n" . "  %s->%s(%s)\n" . "but expected at least one.", get_class($object
    ->reveal()), $method
    ->getMethodName(), $method
    ->getArgumentsWildcard()), $method);
}