From f9e4e62c7d25d5cdf3bf0c4ea981f00fedff3d37 Mon Sep 17 00:00:00 2001 From: Anton Fedurtsya Date: Thu, 21 Mar 2024 13:40:28 +0200 Subject: [PATCH] Cleanup SHOP_ROOT_PATH constant usage cases Signed-off-by: Anton Fedurtsya --- tests/Codeception/Acceptance/_bootstrap.php | 5 ----- tests/Codeception/Config/params.php | 18 ++++++++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/Codeception/Acceptance/_bootstrap.php b/tests/Codeception/Acceptance/_bootstrap.php index e32d091..fec6561 100644 --- a/tests/Codeception/Acceptance/_bootstrap.php +++ b/tests/Codeception/Acceptance/_bootstrap.php @@ -8,8 +8,3 @@ declare(strict_types=1); // This is acceptance bootstrap - -use Symfony\Component\Filesystem\Path; - -$sourcePath = getenv('SHOP_ROOT_PATH') ?: (new \OxidEsales\Facts\Facts())->getShopRootPath(); -require_once Path::join($sourcePath, 'source', 'bootstrap.php'); diff --git a/tests/Codeception/Config/params.php b/tests/Codeception/Config/params.php index 9574916..c23e750 100644 --- a/tests/Codeception/Config/params.php +++ b/tests/Codeception/Config/params.php @@ -12,7 +12,11 @@ use OxidEsales\Facts\Facts; use Symfony\Component\Filesystem\Path; -$facts = new Facts(configFile: getConfigFile()); +if ($shopRootPath = getenv('SHOP_ROOT_PATH')){ + include(Path::join($shopRootPath, 'source', 'bootstrap.php')); +} + +$facts = new Facts(); return [ 'SHOP_URL' => $facts->getShopUrl(), 'SHOP_SOURCE_PATH' => $facts->getSourcePath(), @@ -59,16 +63,10 @@ function getTestFixtureSqlFilePath(): string function getMysqlConfigPath() { - $configFile = getConfigFile(); + $facts = new Facts(); + $configFilePath = Path::join($facts->getSourcePath(), 'config.inc.php'); + $configFile = new ConfigFile($configFilePath); $generator = new DatabaseDefaultsFileGenerator($configFile); return $generator->generate(); } - -function getConfigFile(): ConfigFile -{ - $facts = new Facts(); - $sourcePath = getenv('SHOP_ROOT_PATH') ?: $facts->getShopRootPath(); - $configFilePath = Path::join($sourcePath, 'source', 'config.inc.php'); - return new ConfigFile($configFilePath); -}