You are here

class ElementTextExceptionTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php \Behat\Mink\Tests\Exception\ElementTextExceptionTest

Hierarchy

  • class \Behat\Mink\Tests\Exception\ElementTextExceptionTest extends \Behat\Mink\Tests\Exception\PHPUnit_Framework_TestCase

Expanded class hierarchy of ElementTextExceptionTest

File

vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php, line 7

Namespace

Behat\Mink\Tests\Exception
View source
class ElementTextExceptionTest extends \PHPUnit_Framework_TestCase {
  public function testExceptionToString() {
    $driver = $this
      ->getMock('Behat\\Mink\\Driver\\DriverInterface');
    $element = $this
      ->getElementMock();
    $driver
      ->expects($this
      ->any())
      ->method('getStatusCode')
      ->will($this
      ->returnValue(200));
    $driver
      ->expects($this
      ->any())
      ->method('getCurrentUrl')
      ->will($this
      ->returnValue('http://localhost/test'));
    $element
      ->expects($this
      ->any())
      ->method('getText')
      ->will($this
      ->returnValue("Hello world\nTest\n"));
    $expected = <<<'TXT'
Text error

+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
|  Hello world
|  Test
|
TXT;
    $expected = sprintf($expected . '  ', get_class($driver));
    $exception = new ElementTextException('Text error', $driver, $element);
    $this
      ->assertEquals($expected, $exception
      ->__toString());
  }
  private function getElementMock() {
    return $this
      ->getMockBuilder('Behat\\Mink\\Element\\NodeElement')
      ->disableOriginalConstructor()
      ->getMock();
  }

}

Members