You are here

public function ExpectationException::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/src/Exception/ExpectationException.php \Behat\Mink\Exception\ExpectationException::__construct()

Initializes exception.

Parameters

string $message optional message:

DriverInterface|Session $driver driver instance (or session for BC):

\Exception|null $exception expectation exception:

2 calls to ExpectationException::__construct()
ElementHtmlException::__construct in vendor/behat/mink/src/Exception/ElementHtmlException.php
Initializes exception.
ElementNotFoundException::__construct in vendor/behat/mink/src/Exception/ElementNotFoundException.php
Initializes exception.
2 methods override ExpectationException::__construct()
ElementHtmlException::__construct in vendor/behat/mink/src/Exception/ElementHtmlException.php
Initializes exception.
ElementNotFoundException::__construct in vendor/behat/mink/src/Exception/ElementNotFoundException.php
Initializes exception.

File

vendor/behat/mink/src/Exception/ExpectationException.php, line 35

Class

ExpectationException
Exception thrown for failed expectations.

Namespace

Behat\Mink\Exception

Code

public function __construct($message, $driver, \Exception $exception = null) {
  if ($driver instanceof Session) {
    @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED);
    $this->session = $driver;
    $this->driver = $driver
      ->getDriver();
  }
  elseif (!$driver instanceof DriverInterface) {

    // Trigger an exception as we cannot typehint a disjunction
    throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.');
  }
  else {
    $this->driver = $driver;
  }
  if (!$message && null !== $exception) {
    $message = $exception
      ->getMessage();
  }
  parent::__construct($message, 0, $exception);
}