AbstractConfig.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Behat\Mink\Tests\Driver;
  3. use Behat\Mink\Driver\DriverInterface;
  4. abstract class AbstractConfig
  5. {
  6. /**
  7. * Creates driver instance.
  8. *
  9. * @return DriverInterface
  10. */
  11. abstract public function createDriver();
  12. /**
  13. * Map remote file path.
  14. *
  15. * @param string $file File path.
  16. *
  17. * @return string
  18. */
  19. public function mapRemoteFilePath($file)
  20. {
  21. if (!isset($_SERVER['TEST_MACHINE_BASE_PATH']) || !isset($_SERVER['DRIVER_MACHINE_BASE_PATH'])) {
  22. return $file;
  23. }
  24. $pattern = '/^'.preg_quote($_SERVER['TEST_MACHINE_BASE_PATH'], '/').'/';
  25. $basePath = $_SERVER['DRIVER_MACHINE_BASE_PATH'];
  26. return preg_replace($pattern, $basePath, $file, 1);
  27. }
  28. /**
  29. * Gets the base url to the fixture folder.
  30. *
  31. * @return string
  32. */
  33. public function getWebFixturesUrl()
  34. {
  35. return $_SERVER['WEB_FIXTURES_HOST'];
  36. }
  37. /**
  38. * @param string $testCase The name of the TestCase class
  39. * @param string $test The name of the test method
  40. *
  41. * @return string|null A message explaining why the test should be skipped, or null to run the test.
  42. */
  43. public function skipMessage($testCase, $test)
  44. {
  45. if (!$this->supportsCss() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Css\\')) {
  46. return 'This driver does not support CSS.';
  47. }
  48. if (!$this->supportsJs() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Js\\')) {
  49. return 'This driver does not support JavaScript.';
  50. }
  51. return null;
  52. }
  53. /**
  54. * Whether the JS tests should run or no.
  55. *
  56. * @return bool
  57. */
  58. protected function supportsJs()
  59. {
  60. return true;
  61. }
  62. /**
  63. * Whether the CSS tests should run or no.
  64. *
  65. * @return bool
  66. */
  67. protected function supportsCss()
  68. {
  69. return false;
  70. }
  71. }