Beispiel #1
0
 /**
  * Initializes exception.
  *
  * @param string     $message   optional message
  * @param Session    $session   session instance
  * @param \Exception $exception expectation exception
  */
 public function __construct($message, Session $session, \Exception $exception = null)
 {
     $this->session = $session;
     if (!$message && null !== $exception) {
         $message = $exception->getMessage();
     }
     parent::__construct($message, 0, $exception);
 }
 /**
  * Initializes exception.
  *
  * @param string                  $message   optional message
  * @param DriverInterface|Session $driver    driver instance (or session for BC)
  * @param \Exception|null         $exception expectation exception
  */
 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);
 }
 /**
  * Initializes exception.
  *
  * @param Session $session  session instance
  * @param string  $type     element type
  * @param string  $selector element selector type
  * @param string  $locator  element locator
  */
 public function __construct(Session $session, $type = null, $selector = null, $locator = null)
 {
     $message = '';
     if (null !== $type) {
         $message .= ucfirst($type);
     } else {
         $message .= 'Tag';
     }
     if (null !== $locator) {
         if (null === $selector || in_array($selector, array('css', 'xpath'))) {
             $selector = 'matching ' . ($selector ?: 'locator');
         } else {
             $selector = 'with ' . $selector;
         }
         $message .= ' ' . $selector . ' "' . $locator . '" ';
     }
     $message .= 'not found.';
     parent::__construct($message, $session);
 }
Beispiel #4
0
 /**
  * Initializes exception.
  *
  * @param   string              $message    optional message
  * @param   Behat\Mink\Session  $session    session instance
  * @param   Exception           $exception  expectation exception
  */
 public function __construct($message = null, Session $session, \Exception $exception = null)
 {
     parent::__construct($message ?: $exception->getMessage(), $session);
 }
Beispiel #5
0
 /**
  * Initialises exception.
  *
  * @param Element    $element   optional message
  * @param \Exception $exception exception
  */
 public function __construct(Element $element, \Exception $exception)
 {
     $this->element = $element;
     parent::__construct(sprintf("Exception thrown by %s\n%s", $element->getXpath(), $exception->getMessage()));
 }
Beispiel #6
0
 /**
  * Initializes Mink exception.
  *
  * @param   string              $message
  * @param   Behat\Mink\Session  $session
  * @param   integer             $code
  * @param   \Exception          $previous
  */
 public function __construct($message, Session $session = null, $code = 0, \Exception $previous = null)
 {
     $this->session = $session;
     parent::__construct($message, $code, $previous);
 }