Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -0,0 +1,42 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementException;
/**
* @group legacy
*/
class ElementExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testMessage()
{
$exception = new ElementException($this->getElementMock(), new \Exception('Something went wrong'));
$expectedMessage = "Exception thrown by element XPath\nSomething went wrong";
$this->assertEquals($expectedMessage, $exception->getMessage());
$this->assertEquals($expectedMessage, (string) $exception);
}
public function testElement()
{
$element = $this->getElementMock();
$exception = new ElementException($element, new \Exception('Something went wrong'));
$this->assertSame($element, $exception->getElement());
}
private function getElementMock()
{
$mock = $this->getMockBuilder('Behat\Mink\Element\Element')
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('getXPath')
->will($this->returnValue('element XPath'));
return $mock;
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementHtmlException;
class ElementHtmlExceptionTest 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('getOuterHtml')
->will($this->returnValue("<div>\n <h1>Hello world</h1>\n <p>Test</p>\n</div>"));
$expected = <<<'TXT'
Html error
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| <div>
| <h1>Hello world</h1>
| <p>Test</p>
| </div>
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ElementHtmlException('Html error', $driver, $element);
$this->assertEquals($expected, $exception->__toString());
}
private function getElementMock()
{
return $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementNotFoundException;
class ElementNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider provideExceptionMessage
*/
public function testBuildMessage($message, $type, $selector = null, $locator = null)
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$exception = new ElementNotFoundException($driver, $type, $selector, $locator);
$this->assertEquals($message, $exception->getMessage());
}
public function provideExceptionMessage()
{
return array(
array('Tag not found.', null),
array('Field not found.', 'field'),
array('Tag matching locator "foobar" not found.', null, null, 'foobar'),
array('Tag matching css "foobar" not found.', null, 'css', 'foobar'),
array('Field matching xpath "foobar" not found.', 'Field', 'xpath', 'foobar'),
array('Tag with name "foobar" not found.', null, 'name', 'foobar'),
);
}
/**
* @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 ElementNotFoundException($session);
$this->assertEquals('Tag not found.', $exception->getMessage());
}
}

View file

@ -0,0 +1,48 @@
<?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())
->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();
}
}

View file

@ -0,0 +1,114 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ExpectationException;
class ExpectationExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testEmptyMessageAndPreviousException()
{
$exception = new ExpectationException('', $this->getMock('Behat\Mink\Driver\DriverInterface'), new \Exception('Something failed'));
$this->assertEquals('Something failed', $exception->getMessage());
}
public function testExceptionToString()
{
$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'));
$html = "<html><head><title>Hello</title></head>\n<body>\n<h1>Hello world</h1>\n<p>Test</p>\n</body></html>";
$driver->expects($this->any())
->method('getContent')
->will($this->returnValue($html));
$expected = <<<'TXT'
Expectation failure
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| <body>
| <h1>Hello world</h1>
| <p>Test</p>
| </body>
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ExpectationException('Expectation failure', $driver);
$this->assertEquals($expected, $exception->__toString());
}
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());
}
public function testExceptionWhileRenderingString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$driver->expects($this->any())
->method('getContent')
->will($this->throwException(new \Exception('Broken page')));
$exception = new ExpectationException('Expectation failure', $driver);
$this->assertEquals('Expectation failure', $exception->__toString());
}
/**
* @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());
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ResponseTextException;
class ResponseTextExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionToString()
{
$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'));
$driver->expects($this->any())
->method('getText')
->with('//html')
->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 ResponseTextException('Text error', $driver);
$this->assertEquals($expected, $exception->__toString());
}
}