diff --git a/src/Utils/Composer.php b/src/Utils/Composer.php index ac8815767..cfe86e535 100644 --- a/src/Utils/Composer.php +++ b/src/Utils/Composer.php @@ -32,7 +32,7 @@ public static function vendorDir(?string $path = null): string public static function autoloadPath(): string { /** - * if $_composer_autoload_path is undefined, fall back to vendor/autoload.php in the parent project's directory. + * If `$_composer_autoload_path` is undefined, fall back to `vendor/autoload.php` in the parent project's directory. * * @link https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary */ @@ -40,7 +40,7 @@ public static function autoloadPath(): string if (isset($_composer_autoload_path)) { $autoloadPath = $_composer_autoload_path; } else { - // we use the Codecept class to find the location of Composer's vendor-dir, even if a project has renamed it + // We use the Codecept class to find the location of Composer's vendor-dir, even if a project has renamed it. $vendorDir = dirname((string)(new \ReflectionClass(Codecept::class))->getFilename(), 5); $autoloadPath = $vendorDir . DIRECTORY_SEPARATOR . 'autoload.php'; } diff --git a/tests/unit/lucatume/WPBrowser/Utils/ComposerTest.php b/tests/unit/lucatume/WPBrowser/Utils/ComposerTest.php index e2556ac93..adc0781d4 100644 --- a/tests/unit/lucatume/WPBrowser/Utils/ComposerTest.php +++ b/tests/unit/lucatume/WPBrowser/Utils/ComposerTest.php @@ -225,8 +225,8 @@ public function should_build_on_the_project_composer_file_if_no_composer_file_sp */ public function static_autoload_path_should_return_global_composer_autoload_path(): void { + // Ensure that it's set for this test. global $_composer_autoload_path; - // ensure that it's set for this test $_composer_autoload_path = codecept_root_dir() . 'vendor/autoload.php'; $this->assertSame($_composer_autoload_path, Composer::autoloadPath() ); @@ -240,7 +240,6 @@ public function static_autoload_path_should_return_global_composer_autoload_path */ public function static_autoload_path_should_use_fallback(): void { - global $_composer_autoload_path; // clear value to enable fallback unset($GLOBALS['_composer_autoload_path']);