class BestPracticesTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php \Behat\Mink\Tests\Driver\Basic\BestPracticesTest
This testcase ensures that the driver implementation follows recommended practices for drivers.
Hierarchy
- class \Behat\Mink\Tests\Driver\TestCase extends \Behat\Mink\Tests\Driver\PHPUnit_Framework_TestCase
- class \Behat\Mink\Tests\Driver\Basic\BestPracticesTest
Expanded class hierarchy of BestPracticesTest
File
- vendor/
behat/ mink/ driver-testsuite/ tests/ Basic/ BestPracticesTest.php, line 10
Namespace
Behat\Mink\Tests\Driver\BasicView source
class BestPracticesTest extends TestCase {
public function testExtendsCoreDriver() {
$driver = $this
->createDriver();
$this
->assertInstanceOf('Behat\\Mink\\Driver\\CoreDriver', $driver);
return $driver;
}
/**
* @depends testExtendsCoreDriver
*/
public function testImplementFindXpath() {
$driver = $this
->createDriver();
$this
->assertNotImplementMethod('find', $driver, 'The driver should overwrite `findElementXpaths` rather than `find` for forward compatibility with Mink 2.');
$this
->assertImplementMethod('findElementXpaths', $driver, 'The driver must be able to find elements.');
$this
->assertNotImplementMethod('setSession', $driver, 'The driver should not deal with the Session directly for forward compatibility with Mink 2.');
}
/**
* @dataProvider provideRequiredMethods
*/
public function testImplementBasicApi($method) {
$driver = $this
->createDriver();
$this
->assertImplementMethod($method, $driver, 'The driver is unusable when this method is not implemented.');
}
public function provideRequiredMethods() {
return array(
array(
'start',
),
array(
'isStarted',
),
array(
'stop',
),
array(
'reset',
),
array(
'visit',
),
array(
'getCurrentUrl',
),
array(
'getContent',
),
array(
'click',
),
);
}
private function assertImplementMethod($method, $object, $reason = '') {
$ref = new \ReflectionClass(get_class($object));
$refMethod = $ref
->getMethod($method);
$message = sprintf('The driver should implement the `%s` method.', $method);
if ('' !== $reason) {
$message .= ' ' . $reason;
}
$this
->assertSame($ref->name, $refMethod
->getDeclaringClass()->name, $message);
}
private function assertNotImplementMethod($method, $object, $reason = '') {
$ref = new \ReflectionClass(get_class($object));
$refMethod = $ref
->getMethod($method);
$message = sprintf('The driver should not implement the `%s` method.', $method);
if ('' !== $reason) {
$message .= ' ' . $reason;
}
$this
->assertNotSame($ref->name, $refMethod
->getDeclaringClass()->name, $message);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BestPracticesTest:: |
private | function | ||
BestPracticesTest:: |
private | function | ||
BestPracticesTest:: |
public | function | ||
BestPracticesTest:: |
public | function | ||
BestPracticesTest:: |
public | function | @dataProvider provideRequiredMethods | |
BestPracticesTest:: |
public | function | @depends testExtendsCoreDriver | |
TestCase:: |
private static | property | ||
TestCase:: |
private static | property | Mink session manager. | |
TestCase:: |
protected | function | ||
TestCase:: |
protected | function | Creates a new driver instance. | |
TestCase:: |
protected | function | ||
TestCase:: |
protected | function | Returns assert session. | |
TestCase:: |
private static | function | ||
TestCase:: |
protected | function | Returns session. | |
TestCase:: |
protected | function | Map remote file path. | |
TestCase:: |
protected | function | ||
TestCase:: |
protected | function | ||
TestCase:: |
protected | function | Waits for a condition to be true, considering than it is successful for drivers not supporting wait(). | |
TestCase:: |
public static | function | Initializes the test case. | |
TestCase:: |
protected | function |