You are here

public function ExpectationExceptionTest::testBigContent in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php \Behat\Mink\Tests\Exception\ExpectationExceptionTest::testBigContent()

File

vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php, line 51

Class

ExpectationExceptionTest

Namespace

Behat\Mink\Tests\Exception

Code

public function testBigContent() {
  $driver = $this
    ->getMock('Behat\\Mink\\Driver\\DriverInterface');
  $driver
    ->expects($this
    ->any())
    ->method('getStatusCode')
    ->will($this
    ->returnValue(200));
  $driver
    ->expects($this
    ->any())
    ->method('getCurrentUrl')
    ->will($this
    ->returnValue('http://localhost/test'));
  $body = str_repeat('a', 1001 - strlen('<body></body>'));
  $html = sprintf("<html><head><title>Hello</title></head>\n<body>%s</body></html>", $body);
  $driver
    ->expects($this
    ->any())
    ->method('getContent')
    ->will($this
    ->returnValue($html));
  $expected = <<<'TXT'
Expectation failure

+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
|  <body>%s</b...
|
TXT;
  $expected = sprintf($expected . '  ', get_class($driver), $body);
  $exception = new ExpectationException('Expectation failure', $driver);
  $this
    ->assertEquals($expected, $exception
    ->__toString());
}