public function testExceptionWhileRenderingString()
 {
     $session = $this->getSessionMock();
     $session->expects($this->any())->method('getPage')->will($this->throwException(new \Exception('Broken page')));
     $exception = new ExpectationException('Expectation failure', $session);
     $this->assertEquals('Expectation failure', $exception->__toString());
 }
Ejemplo n.º 2
0
 /**
  * @group legacy
  */
 public function testConstructWithSession()
 {
     $driver = $this->getMock('Behat\\Mink\\Driver\\DriverInterface');
     $session = $this->getMockBuilder('Behat\\Mink\\Session')->disableOriginalConstructor()->getMock();
     $session->expects($this->any())->method('getDriver')->will($this->returnValue($driver));
     $exception = new ExpectationException('', $session, new \Exception('Something failed'));
     $this->assertEquals('Something failed', $exception->getMessage());
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * Initializes exception.
  *
  * @param string                  $message   optional message
  * @param DriverInterface|Session $driver    driver instance
  * @param Element                 $element   element
  * @param \Exception              $exception expectation exception
  */
 public function __construct($message, $driver, Element $element, \Exception $exception = null)
 {
     $this->element = $element;
     parent::__construct($message, $driver, $exception);
 }
Ejemplo n.º 5
0
 /**
  * Initializes exception.
  *
  * @param   string                      $message    optional message
  * @param   Behat\Mink\Session          $session    session instance
  * @param   Behat\Mink\Element\Element  $element    element
  * @param   Exception                   $exception  expectation exception
  */
 public function __construct($message = null, Session $session, Element $element, \Exception $exception = null)
 {
     $this->element = $element;
     parent::__construct($message, $session, $exception);
 }