autoload.php 4.6 KB

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