From 0deefef584e2ab6d1ff5867a1ba56f4616df4ec3 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Tue, 20 May 2025 20:11:37 -0700 Subject: [PATCH] test: default timezone must be 'America/Chicago' for unit tests There can be failures in the unit tests at certain times if the default timezone in `config.php` isn't "America/Chicago". Use "America/Chicago" in the CI and fail `phpunit` early if `config.php` has a different value. Closes: #544 --- .github/workflows/lint-and-analyse-php.yml | 3 +++ tests/autoload.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/lint-and-analyse-php.yml b/.github/workflows/lint-and-analyse-php.yml index defd7f7e0..3b1b593ad 100644 --- a/.github/workflows/lint-and-analyse-php.yml +++ b/.github/workflows/lint-and-analyse-php.yml @@ -61,6 +61,9 @@ jobs: - name: Create config.php for unit tests run: cp config/config.dist.php config/config.php + - name: Change timezone to 'America/Chicago' in config.php + run: sed -i 's+Etc/UTC+America/Chicago+g' config/config.php + - name: Unit Tests run: composer phpunit diff --git a/tests/autoload.php b/tests/autoload.php index 1cefd85a0..03aa463c2 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -10,3 +10,8 @@ require_once(ROOT_DIR . 'tests/fakes/namespace.php'); require_once(ROOT_DIR . 'lib/Common/Helpers/namespace.php'); + +if (Configuration::Instance()->GetDefaultTimezone() != "America/Chicago") { + echo "\nERROR: Default timezone in 'config/config.php' must be 'America/Chicago in order to run unit tests.\n"; + exit(1); +}