autoload.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // for phar
  3. if (file_exists(__DIR__.'/vendor/autoload.php')) {
  4. require_once(__DIR__.'/vendor/autoload.php');
  5. } elseif (file_exists(__DIR__.'/../../autoload.php')) {
  6. require_once __DIR__ . '/../../autoload.php';
  7. }
  8. // @codingStandardsIgnoreStart
  9. // loading WebDriver aliases
  10. if (!class_exists('RemoteWebDriver') and class_exists('Facebook\WebDriver\Remote\RemoteWebDriver')) {
  11. class RemoteWebDriver extends \Facebook\WebDriver\Remote\RemoteWebDriver {};
  12. class InvalidSelectorException extends Facebook\WebDriver\Exception\InvalidSelectorException {};
  13. class NoSuchElementException extends Facebook\WebDriver\Exception\NoSuchElementException {};
  14. class WebDriverCurlException extends Facebook\WebDriver\Exception\WebDriverCurlException {};
  15. class WebDriverActions extends Facebook\WebDriver\Interactions\WebDriverActions {};
  16. class LocalFileDetector extends Facebook\WebDriver\Remote\LocalFileDetector {};
  17. class WebDriverCapabilityType extends Facebook\WebDriver\Remote\WebDriverCapabilityType {};
  18. class WebDriverAlert extends Facebook\WebDriver\WebDriverAlert {};
  19. class WebDriverBy extends Facebook\WebDriver\WebDriverBy {};
  20. class WebDriverDimension extends Facebook\WebDriver\WebDriverDimension {};
  21. class RemoteWebElement extends Facebook\WebDriver\Remote\RemoteWebElement {};
  22. class WebDriverExpectedCondition extends Facebook\WebDriver\WebDriverExpectedCondition {};
  23. class WebDriverKeys extends Facebook\WebDriver\WebDriverKeys {};
  24. class WebDriverSelect extends Facebook\WebDriver\WebDriverSelect {};
  25. class WebDriverTimeouts extends Facebook\WebDriver\WebDriverTimeouts {};
  26. class WebDriverWindow extends Facebook\WebDriver\WebDriverWindow {};
  27. interface WebDriverElement extends Facebook\WebDriver\WebDriverElement {};
  28. }
  29. include_once __DIR__ . DIRECTORY_SEPARATOR . 'shim.php';
  30. // compat
  31. if (PHP_MAJOR_VERSION < 7) {
  32. if (false === interface_exists('Throwable', false)) {
  33. interface Throwable {};
  34. }
  35. if (false === class_exists('ParseError', false)) {
  36. class ParseError extends \Exception {};
  37. }
  38. }
  39. // @codingStandardsIgnoreEnd
  40. if (!function_exists('json_last_error_msg')) {
  41. /**
  42. * Copied from http://php.net/manual/en/function.json-last-error-msg.php#117393
  43. * @return string
  44. */
  45. function json_last_error_msg()
  46. {
  47. static $errors = array(
  48. JSON_ERROR_NONE => 'No error',
  49. JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
  50. JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
  51. JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
  52. JSON_ERROR_SYNTAX => 'Syntax error',
  53. JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
  54. );
  55. $error = json_last_error();
  56. return isset($errors[$error]) ? $errors[$error] : 'Unknown error';
  57. }
  58. }
  59. // function not autoloaded in PHP, thus its a good place for them
  60. if (!function_exists('codecept_debug')) {
  61. function codecept_debug($data)
  62. {
  63. \Codeception\Util\Debug::debug($data);
  64. }
  65. }
  66. if (!function_exists('codecept_root_dir')) {
  67. function codecept_root_dir($appendPath = '')
  68. {
  69. return \Codeception\Configuration::projectDir() . $appendPath;
  70. }
  71. }
  72. if (!function_exists('codecept_output_dir')) {
  73. function codecept_output_dir($appendPath = '')
  74. {
  75. return \Codeception\Configuration::outputDir() . $appendPath;
  76. }
  77. }
  78. if (!function_exists('codecept_log_dir')) {
  79. function codecept_log_dir($appendPath = '')
  80. {
  81. return \Codeception\Configuration::outputDir() . $appendPath;
  82. }
  83. }
  84. if (!function_exists('codecept_data_dir')) {
  85. function codecept_data_dir($appendPath = '')
  86. {
  87. return \Codeception\Configuration::dataDir() . $appendPath;
  88. }
  89. }
  90. if (!function_exists('codecept_relative_path')) {
  91. function codecept_relative_path($path)
  92. {
  93. return \Codeception\Util\PathResolver::getRelativeDir(
  94. $path,
  95. \Codeception\Configuration::projectDir(),
  96. DIRECTORY_SEPARATOR
  97. );
  98. }
  99. }