You are here

public function ObjectProphecy::addMethodProphecy in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php \Prophecy\Prophecy\ObjectProphecy::addMethodProphecy()

Adds method prophecy to object prophecy.

Parameters

MethodProphecy $methodProphecy:

Throws

\Prophecy\Exception\Prophecy\MethodProphecyException If method prophecy doesn't have arguments wildcard

File

vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php, line 137

Class

ObjectProphecy
Object prophecy.

Namespace

Prophecy\Prophecy

Code

public function addMethodProphecy(MethodProphecy $methodProphecy) {
  $argumentsWildcard = $methodProphecy
    ->getArgumentsWildcard();
  if (null === $argumentsWildcard) {
    throw new MethodProphecyException(sprintf("Can not add prophecy for a method `%s::%s()`\n" . "as you did not specify arguments wildcard for it.", get_class($this
      ->reveal()), $methodProphecy
      ->getMethodName()), $methodProphecy);
  }
  $methodName = $methodProphecy
    ->getMethodName();
  if (!isset($this->methodProphecies[$methodName])) {
    $this->methodProphecies[$methodName] = array();
  }
  $this->methodProphecies[$methodName][] = $methodProphecy;
}