From d64334885231f534546486759f3ba2753aa96536 Mon Sep 17 00:00:00 2001 From: Vasyl Liulka Date: Wed, 13 Nov 2024 15:02:09 +0100 Subject: [PATCH] OXDEV-7248 Add default timezone config --- .env.dist | 1 + .../Utility/BasicContextInterface.php | 4 +++ source/bootstrap.php | 2 ++ tests/Codeception/Acceptance.suite.yml | 3 +- .../Acceptance/Admin/SystemInfoCest.php | 29 +++++++++++++++++++ tests/ConsoleRunnerTrait.php | 4 ++- tests/Unit/Internal/BasicContextStub.php | 10 +++---- 7 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 tests/Codeception/Acceptance/Admin/SystemInfoCest.php diff --git a/.env.dist b/.env.dist index cc4ee77b96..27a63ee247 100644 --- a/.env.dist +++ b/.env.dist @@ -1,4 +1,5 @@ OXID_ENV=prod +OXID_DEFAULT_TIMEZONE=Europe/Berlin OXID_LOG_LEVEL=error OXID_DEBUG_MODE=false OXID_DB_URL=mysql://root:root@mysql:3306/example?charset=utf8&driverOptions[1002]="SET @@SESSION.sql_mode=\"\"" diff --git a/source/Internal/Transition/Utility/BasicContextInterface.php b/source/Internal/Transition/Utility/BasicContextInterface.php index ddb5fb7436..3b8e41a89a 100644 --- a/source/Internal/Transition/Utility/BasicContextInterface.php +++ b/source/Internal/Transition/Utility/BasicContextInterface.php @@ -8,6 +8,7 @@ namespace OxidEsales\EshopCommunity\Internal\Transition\Utility; use OxidEsales\EshopCommunity\Internal\Framework\Edition\Edition; +use OxidEsales\EshopCommunity\Internal\Framework\FileSystem\DirectoryNotExistentException; interface BasicContextInterface { @@ -31,6 +32,9 @@ public function getDefaultShopId(): int; public function getEdition(): Edition; + /** + * @throws DirectoryNotExistentException + */ public function getEditionSourcePath(Edition $edition): string; public function getGeneratedServicesFilePath(): string; diff --git a/source/bootstrap.php b/source/bootstrap.php index 757e68e75f..cf39a64e55 100644 --- a/source/bootstrap.php +++ b/source/bootstrap.php @@ -76,3 +76,5 @@ static function () { ini_set('url_rewriter.tags', ''); (new DotenvLoader(INSTALLATION_ROOT_PATH))->loadEnvironmentVariables(); + +date_default_timezone_set(getenv('OXID_DEFAULT_TIMEZONE')); diff --git a/tests/Codeception/Acceptance.suite.yml b/tests/Codeception/Acceptance.suite.yml index 31bd5aae58..b5166c4749 100644 --- a/tests/Codeception/Acceptance.suite.yml +++ b/tests/Codeception/Acceptance.suite.yml @@ -9,7 +9,7 @@ modules: browser: '%BROWSER%' port: '%SELENIUM_SERVER_PORT%' host: '%SELENIUM_SERVER_HOST%' - window_size: 2000x2000 + window_size: maximize clear_cookies: true restart: true capabilities: @@ -23,6 +23,7 @@ modules: mysql_config: '%MYSQL_CONFIG_PATH%' db_name: '%DB_NAME%' out_directory_fixtures: '%OUT_DIRECTORY_FIXTURES%' + out_directory: '%OUT_DIRECTORY%' - Db: dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%;charset=utf8' user: '%DB_USERNAME%' diff --git a/tests/Codeception/Acceptance/Admin/SystemInfoCest.php b/tests/Codeception/Acceptance/Admin/SystemInfoCest.php new file mode 100644 index 0000000000..81a25f8b4a --- /dev/null +++ b/tests/Codeception/Acceptance/Admin/SystemInfoCest.php @@ -0,0 +1,29 @@ +wantToTest('the default timezone is set on application start.'); + + $I->loginAdmin() + ->openSystemInfo() + ->setRowInDateTable( + 'Default timezone', + getenv('OXID_DEFAULT_TIMEZONE') + ); + } +} diff --git a/tests/ConsoleRunnerTrait.php b/tests/ConsoleRunnerTrait.php index 2300f96ea0..90d81faabd 100644 --- a/tests/ConsoleRunnerTrait.php +++ b/tests/ConsoleRunnerTrait.php @@ -13,12 +13,14 @@ use RuntimeException; use Symfony\Component\Process\Process; +use function sprintf; + trait ConsoleRunnerTrait { public function runInConsole(string $command): Process { $process = Process::fromShellCommandline( - "{$this->getPathToConsoleScript()} {$command}" + "{$this->getPathToConsoleScript()} $command" ); $process->run(); diff --git a/tests/Unit/Internal/BasicContextStub.php b/tests/Unit/Internal/BasicContextStub.php index 0f2b525704..dbab874b77 100644 --- a/tests/Unit/Internal/BasicContextStub.php +++ b/tests/Unit/Internal/BasicContextStub.php @@ -56,9 +56,6 @@ public function __construct() $this->databaseUrl = $basicContext->getDatabaseUrl(); $this->projectConfigurationDirectory = $basicContext->getProjectConfigurationDirectory(); $this->shopBaseUrl = $basicContext->getShopBaseUrl(); - $this->ceSourcePath = $basicContext->getEditionSourcePath(Edition::Community); - $this->peSourcePath = $basicContext->getEditionSourcePath(Edition::Professional); - $this->eeSourcePath = $basicContext->getEditionSourcePath(Edition::Enterprise); } public function getContainerCacheFilePath(int $shopId): string @@ -203,10 +200,11 @@ public function setShopBaseUrl(string $shopBaseUrl): void public function getEditionSourcePath(Edition $edition): string { + $basicContext = BootstrapContainerFactory::getBootstrapContainer()->get(BasicContextInterface::class); return match ($edition) { - Edition::Community => $this->ceSourcePath, - Edition::Professional => $this->peSourcePath, - Edition::Enterprise => $this->eeSourcePath, + Edition::Community => $this->ceSourcePath ?? $basicContext->getEditionSourcePath(Edition::Community), + Edition::Professional => $this->peSourcePath ?? $basicContext->getEditionSourcePath(Edition::Professional), + Edition::Enterprise => $this->eeSourcePath ?? $basicContext->getEditionSourcePath(Edition::Enterprise), }; }