Skip to content

Commit

Permalink
Increase the code coverage (line coverage is now 100%)
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Jan 24, 2015
1 parent 165d5a4 commit 1b16b2a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
42 changes: 42 additions & 0 deletions tests/Exception/ExpectationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,48 @@ public function testExceptionToString()
$this->assertEquals($expected, $exception->__toString());
}

public function testBigContent()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$page = $this->getPageMock();

$session = $this->getSessionMock();
$session->expects($this->any())
->method('getDriver')
->will($this->returnValue($driver));
$session->expects($this->any())
->method('getPage')
->will($this->returnValue($page));
$session->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$session->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);
$page->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', $session);

$this->assertEquals($expected, $exception->__toString());
}

public function testExceptionWhileRenderingString()
{
$session = $this->getSessionMock();
Expand Down
12 changes: 12 additions & 0 deletions tests/Selector/SelectorsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,16 @@ public function testXpathLiteral()

$this->assertEquals("'some simple string'", $handler->xpathLiteral('some simple string'));
}

public function testBcLayer()
{
$selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock();
$handler = new SelectorsHandler();

$handler->registerSelector('named_partial', $selector);

$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$this->assertSame($selector, $handler->getSelector('named'));
}
}
11 changes: 9 additions & 2 deletions tests/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class SessionTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->driver = $this->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock();
$this->driver = $this->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock();
$this->selectorsHandler = $this->getMockBuilder('Behat\Mink\Selector\SelectorsHandler')->getMock();
$this->session = new Session($this->driver, $this->selectorsHandler);
$this->session = new Session($this->driver, $this->selectorsHandler);
}

public function testGetDriver()
Expand All @@ -41,6 +41,13 @@ public function testGetSelectorsHandler()
$this->assertSame($this->selectorsHandler, $this->session->getSelectorsHandler());
}

public function testInstantiateWithoutOptionalDeps()
{
$session = new Session($this->driver);

$this->assertInstanceOf('Behat\Mink\Selector\SelectorsHandler', $session->getSelectorsHandler());
}

public function testIsStarted()
{
$this->driver->expects($this->once())
Expand Down

0 comments on commit 1b16b2a

Please sign in to comment.