-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathElementNotFoundExceptionTest.php
51 lines (42 loc) · 1.69 KB
/
ElementNotFoundExceptionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementNotFoundException;
use PHPUnit\Framework\TestCase;
class ElementNotFoundExceptionTest extends TestCase
{
/**
* @dataProvider provideExceptionMessage
*/
public function testBuildMessage(string $message, ?string $type, ?string $selector = null, ?string $locator = null)
{
$driver = $this->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock();
$exception = new ElementNotFoundException($driver, $type, $selector, $locator);
$this->assertEquals($message, $exception->getMessage());
}
public static 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->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock();
$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());
}
}