From 1bf023922c03bfc2fa0e3ad30356973fa6c107af Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Thu, 17 Oct 2024 07:43:31 +1100 Subject: [PATCH] [#1422] Renamed `ENVIRONMENT_TEST` to `ENVIRONMENT_STAGE`. --- .vortex/docs/content/drupal/settings.mdx | 2 +- .../Drupal/EnvironmentSettingsTest.php | 30 +++++++++++-------- tests/phpunit/Drupal/SettingsTestCase.php | 4 +-- .../phpunit/Drupal/SwitchableSettingsTest.php | 10 +++---- .../modules/settings.config_split.php | 2 +- .../settings.environment_indicator.php | 2 +- .../includes/providers/settings.acquia.php | 3 +- .../includes/providers/settings.lagoon.php | 4 +-- web/sites/default/settings.php | 4 +-- 9 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.vortex/docs/content/drupal/settings.mdx b/.vortex/docs/content/drupal/settings.mdx index 9fc57b9b6..9e836866a 100644 --- a/.vortex/docs/content/drupal/settings.mdx +++ b/.vortex/docs/content/drupal/settings.mdx @@ -50,7 +50,7 @@ Available constants include: - `ENVIRONMENT_LOCAL` - `ENVIRONMENT_CI` - `ENVIRONMENT_PROD` -- `ENVIRONMENT_TEST` +- `ENVIRONMENT_STAGE` - `ENVIRONMENT_DEV` These are later used to set `$settings['environment']` variable, which can be diff --git a/tests/phpunit/Drupal/EnvironmentSettingsTest.php b/tests/phpunit/Drupal/EnvironmentSettingsTest.php index 332d1f3ea..cfdfc0f3b 100644 --- a/tests/phpunit/Drupal/EnvironmentSettingsTest.php +++ b/tests/phpunit/Drupal/EnvironmentSettingsTest.php @@ -66,11 +66,17 @@ public function dataProviderEnvironmentTypeResolution(): array { ], static::ENVIRONMENT_PROD, ], + [ + [ + 'AH_SITE_ENVIRONMENT' => 'stage', + ], + static::ENVIRONMENT_STAGE, + ], [ [ 'AH_SITE_ENVIRONMENT' => 'test', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ [ @@ -123,7 +129,7 @@ public function dataProviderEnvironmentTypeResolution(): array { 'VORTEX_LAGOON_PRODUCTION_BRANCH' => 'master', 'LAGOON_ENVIRONMENT_TYPE' => 'development', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ [ @@ -132,7 +138,7 @@ public function dataProviderEnvironmentTypeResolution(): array { 'VORTEX_LAGOON_PRODUCTION_BRANCH' => FALSE, 'LAGOON_ENVIRONMENT_TYPE' => 'development', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ [ @@ -150,7 +156,7 @@ public function dataProviderEnvironmentTypeResolution(): array { 'VORTEX_LAGOON_PRODUCTION_BRANCH' => FALSE, 'LAGOON_ENVIRONMENT_TYPE' => 'development', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ [ @@ -176,7 +182,7 @@ public function dataProviderEnvironmentTypeResolution(): array { 'LAGOON_ENVIRONMENT_TYPE' => 'development', 'LAGOON_GIT_BRANCH' => 'release/1.2.3', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ [ @@ -192,7 +198,7 @@ public function dataProviderEnvironmentTypeResolution(): array { 'LAGOON_ENVIRONMENT_TYPE' => 'development', 'LAGOON_GIT_BRANCH' => 'hotfix/1.2.3', ], - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, ], [ @@ -498,9 +504,9 @@ public function testEnvironmentAcquiaDev(): void { /** * Test per-environment settings for Test environment. */ - public function testEnvironmentAcquiaTest(): void { + public function testEnvironmentAcquiaStage(): void { $this->setEnvVars([ - 'AH_SITE_ENVIRONMENT' => 'test', + 'AH_SITE_ENVIRONMENT' => 'stage', ]); $this->requireSettingsFile(); @@ -509,7 +515,7 @@ public function testEnvironmentAcquiaTest(): void { $config['config_split.config_split.test']['status'] = TRUE; $config['environment_indicator.indicator']['bg_color'] = '#fff176'; $config['environment_indicator.indicator']['fg_color'] = '#000000'; - $config['environment_indicator.indicator']['name'] = static::ENVIRONMENT_TEST; + $config['environment_indicator.indicator']['name'] = static::ENVIRONMENT_STAGE; $config['environment_indicator.settings']['favicon'] = TRUE; $config['environment_indicator.settings']['toolbar_integration'] = [TRUE]; $config['maintenance_theme'] = 'your_site_theme'; @@ -523,7 +529,7 @@ public function testEnvironmentAcquiaTest(): void { $settings['config_sync_directory'] = static::CONFIG_PATH_TESTING; $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml'; $settings['entity_update_batch_size'] = 50; - $settings['environment'] = static::ENVIRONMENT_TEST; + $settings['environment'] = static::ENVIRONMENT_STAGE; $settings['file_private_path'] = static::PRIVATE_PATH_TESTING; $settings['file_scan_ignore_directories'] = [ 'node_modules', @@ -700,7 +706,7 @@ public function testEnvironmentLagoonTest(): void { $config['config_split.config_split.test']['status'] = TRUE; $config['environment_indicator.indicator']['bg_color'] = '#fff176'; $config['environment_indicator.indicator']['fg_color'] = '#000000'; - $config['environment_indicator.indicator']['name'] = static::ENVIRONMENT_TEST; + $config['environment_indicator.indicator']['name'] = static::ENVIRONMENT_STAGE; $config['environment_indicator.settings']['favicon'] = TRUE; $config['environment_indicator.settings']['toolbar_integration'] = [TRUE]; $config['maintenance_theme'] = 'your_site_theme'; @@ -715,7 +721,7 @@ public function testEnvironmentLagoonTest(): void { $settings['config_sync_directory'] = static::CONFIG_PATH_TESTING; $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml'; $settings['entity_update_batch_size'] = 50; - $settings['environment'] = static::ENVIRONMENT_TEST; + $settings['environment'] = static::ENVIRONMENT_STAGE; $settings['file_private_path'] = static::PRIVATE_PATH_TESTING; $settings['file_scan_ignore_directories'] = [ 'node_modules', diff --git a/tests/phpunit/Drupal/SettingsTestCase.php b/tests/phpunit/Drupal/SettingsTestCase.php index 7f213e255..3c4128925 100644 --- a/tests/phpunit/Drupal/SettingsTestCase.php +++ b/tests/phpunit/Drupal/SettingsTestCase.php @@ -40,9 +40,9 @@ abstract class SettingsTestCase extends TestCase { final const ENVIRONMENT_PROD = 'prod'; /** - * Defines a constant for the name of the 'test' environment. + * Defines a constant for the name of the 'stage' environment. */ - final const ENVIRONMENT_TEST = 'test'; + final const ENVIRONMENT_STAGE = 'stage'; /** * Defines a constant for the name of the 'dev' environment. diff --git a/tests/phpunit/Drupal/SwitchableSettingsTest.php b/tests/phpunit/Drupal/SwitchableSettingsTest.php index 7b71d2337..75802a7b5 100644 --- a/tests/phpunit/Drupal/SwitchableSettingsTest.php +++ b/tests/phpunit/Drupal/SwitchableSettingsTest.php @@ -128,7 +128,7 @@ public static function dataProviderConfigSplit(): array { ], ], [ - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, [ 'config_split.config_split.test' => ['status' => TRUE], ], @@ -204,9 +204,9 @@ public static function dataProviderEnvironmentIndicator(): array { ], ], [ - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, [ - 'environment_indicator.indicator' => ['name' => static::ENVIRONMENT_TEST, 'bg_color' => '#fff176', 'fg_color' => '#000000'], + 'environment_indicator.indicator' => ['name' => static::ENVIRONMENT_STAGE, 'bg_color' => '#fff176', 'fg_color' => '#000000'], 'environment_indicator.settings' => ['toolbar_integration' => [TRUE], 'favicon' => TRUE], ], ], @@ -353,7 +353,7 @@ public static function dataProviderShield(): array { ], [ - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, [ 'DRUPAL_SHIELD_USER' => 'drupal_shield_user', 'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass', @@ -481,7 +481,7 @@ public static function dataProviderStageFileProxy(): array { ], [ - static::ENVIRONMENT_TEST, + static::ENVIRONMENT_STAGE, [ 'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/', 'DRUPAL_SHIELD_USER' => 'drupal_shield_user', diff --git a/web/sites/default/includes/modules/settings.config_split.php b/web/sites/default/includes/modules/settings.config_split.php index 108c82292..dea1150be 100644 --- a/web/sites/default/includes/modules/settings.config_split.php +++ b/web/sites/default/includes/modules/settings.config_split.php @@ -8,7 +8,7 @@ declare(strict_types=1); switch ($settings['environment']) { - case ENVIRONMENT_TEST: + case ENVIRONMENT_STAGE: $config['config_split.config_split.test']['status'] = TRUE; break; diff --git a/web/sites/default/includes/modules/settings.environment_indicator.php b/web/sites/default/includes/modules/settings.environment_indicator.php index 121f987e5..5dc16da52 100644 --- a/web/sites/default/includes/modules/settings.environment_indicator.php +++ b/web/sites/default/includes/modules/settings.environment_indicator.php @@ -19,7 +19,7 @@ $config['environment_indicator.indicator']['fg_color'] = '#000000'; break; - case ENVIRONMENT_TEST: + case ENVIRONMENT_STAGE: $config['environment_indicator.indicator']['bg_color'] = '#fff176'; $config['environment_indicator.indicator']['fg_color'] = '#000000'; break; diff --git a/web/sites/default/includes/providers/settings.acquia.php b/web/sites/default/includes/providers/settings.acquia.php index 32d408e91..04a16fb89 100644 --- a/web/sites/default/includes/providers/settings.acquia.php +++ b/web/sites/default/includes/providers/settings.acquia.php @@ -38,8 +38,9 @@ $settings['environment'] = ENVIRONMENT_PROD; break; + case 'stage': case 'test': - $settings['environment'] = ENVIRONMENT_TEST; + $settings['environment'] = ENVIRONMENT_STAGE; break; } } diff --git a/web/sites/default/includes/providers/settings.lagoon.php b/web/sites/default/includes/providers/settings.lagoon.php index 24c3d5b3a..087e20452 100644 --- a/web/sites/default/includes/providers/settings.lagoon.php +++ b/web/sites/default/includes/providers/settings.lagoon.php @@ -28,12 +28,12 @@ } // Dedicated test environment based on a branch name. elseif (getenv('LAGOON_GIT_BRANCH') == 'main' || getenv('LAGOON_GIT_BRANCH') == 'master') { - $settings['environment'] = ENVIRONMENT_TEST; + $settings['environment'] = ENVIRONMENT_STAGE; } // Test environment based on a branch prefix for release and // hotfix branches. elseif (!empty(getenv('LAGOON_GIT_BRANCH')) && (str_starts_with(getenv('LAGOON_GIT_BRANCH'), 'release/') || str_starts_with(getenv('LAGOON_GIT_BRANCH'), 'hotfix/'))) { - $settings['environment'] = ENVIRONMENT_TEST; + $settings['environment'] = ENVIRONMENT_STAGE; } } diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index 82e8b62c1..5799835f3 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -37,8 +37,8 @@ if (!defined('ENVIRONMENT_PROD')) { define('ENVIRONMENT_PROD', 'prod'); } -if (!defined('ENVIRONMENT_TEST')) { - define('ENVIRONMENT_TEST', 'test'); +if (!defined('ENVIRONMENT_STAGE')) { + define('ENVIRONMENT_STAGE', 'stage'); } if (!defined('ENVIRONMENT_DEV')) { define('ENVIRONMENT_DEV', 'dev');