You are here

public function MethodProphecy::will in Zircon Profile 8

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

Sets custom promise to the prophecy.

Parameters

callable|Promise\PromiseInterface $promise:

Return value

$this

Throws

\Prophecy\Exception\InvalidArgumentException

4 calls to MethodProphecy::will()
MethodProphecy::willReturn in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Sets return promise to the prophecy.
MethodProphecy::willReturnArgument in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Sets return argument promise to the prophecy.
MethodProphecy::willThrow in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Sets throw promise to the prophecy.
MethodProphecy::__construct in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
Initializes method prophecy.

File

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

Class

MethodProphecy
Method prophecy.

Namespace

Prophecy\Prophecy

Code

public function will($promise) {
  if (is_callable($promise)) {
    $promise = new Promise\CallbackPromise($promise);
  }
  if (!$promise instanceof Promise\PromiseInterface) {
    throw new InvalidArgumentException(sprintf('Expected callable or instance of PromiseInterface, but got %s.', gettype($promise)));
  }
  $this
    ->bindToObjectProphecy();
  $this->promise = $promise;
  return $this;
}