forked from minkphp/driver-testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractConfig.php
87 lines (74 loc) · 2.05 KB
/
AbstractConfig.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace Behat\Mink\Tests\Driver;
use Behat\Mink\Driver\DriverInterface;
abstract class AbstractConfig
{
/**
* Creates driver instance.
*
* @return DriverInterface
*/
abstract public function createDriver();
/**
* Map remote file path.
*
* @param string $file File path
*
* @return string
*/
public function mapRemoteFilePath($file)
{
if (!isset($_SERVER['TEST_MACHINE_BASE_PATH'], $_SERVER['DRIVER_MACHINE_BASE_PATH'])) {
return $file;
}
$pattern = '/^' . preg_quote($_SERVER['TEST_MACHINE_BASE_PATH'], '/') . '/';
$basePath = $_SERVER['DRIVER_MACHINE_BASE_PATH'];
return preg_replace($pattern, $basePath, $file, 1) ?? $file;
}
/**
* Gets the base url to the fixture folder.
*
* @return string
*/
public function getWebFixturesUrl()
{
if (!isset($_SERVER['WEB_FIXTURES_HOST'])) {
return 'http://localhost:8002'; // Host used by default by mink-test-server
}
return $_SERVER['WEB_FIXTURES_HOST'];
}
/**
* @param string $testCase The name of the TestCase class
* @param string $test The name of the test method
*
* @return string|null A message explaining why the test should be skipped, or null to run the test
*/
public function skipMessage($testCase, $test)
{
if (!$this->supportsCss() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Css\\')) {
return 'This driver does not support CSS.';
}
if (!$this->supportsJs() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Js\\')) {
return 'This driver does not support JavaScript.';
}
return null;
}
/**
* Whether the JS tests should run or no.
*
* @return bool
*/
protected function supportsJs()
{
return true;
}
/**
* Whether the CSS tests should run or no.
*
* @return bool
*/
protected function supportsCss()
{
return false;
}
}