Skip to content

Commit

Permalink
OXDEV-7248 Add default timezone config
Browse files Browse the repository at this point in the history
  • Loading branch information
liulka-oxid committed Nov 13, 2024
1 parent 06f43ec commit d643348
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -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=\"\""
Expand Down
4 changes: 4 additions & 0 deletions source/Internal/Transition/Utility/BasicContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -31,6 +32,9 @@ public function getDefaultShopId(): int;

public function getEdition(): Edition;

/**
* @throws DirectoryNotExistentException
*/
public function getEditionSourcePath(Edition $edition): string;

public function getGeneratedServicesFilePath(): string;
Expand Down
2 changes: 2 additions & 0 deletions source/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
3 changes: 2 additions & 1 deletion tests/Codeception/Acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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%'
Expand Down
29 changes: 29 additions & 0 deletions tests/Codeception/Acceptance/Admin/SystemInfoCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\EshopCommunity\Tests\Codeception\Acceptance\Admin;

use Codeception\Attribute\Group;
use OxidEsales\EshopCommunity\Tests\Codeception\Support\AcceptanceTester;

#[Group('admin', 'system-info')]
final class SystemInfoCest
{
public function defaultTimezone(AcceptanceTester $I): void
{
$I->wantToTest('the default timezone is set on application start.');

$I->loginAdmin()
->openSystemInfo()
->setRowInDateTable(
'Default timezone',
getenv('OXID_DEFAULT_TIMEZONE')
);
}
}
4 changes: 3 additions & 1 deletion tests/ConsoleRunnerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 4 additions & 6 deletions tests/Unit/Internal/BasicContextStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
};
}

Expand Down

0 comments on commit d643348

Please sign in to comment.