Newer
Older
Angie Byron
committed
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementTextException;
class ElementTextExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionToString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$element = $this->getElementMock();
$driver->expects($this->any())
Angie Byron
committed
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
Angie Byron
committed
->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);
Angie Byron
committed
$this->assertEquals($expected, $exception->__toString());
}
private function getElementMock()
{
return $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
}
}