Summary
After the DRUPAL_ENVIRONMENT -> ENVIRONMENT_TYPE rename in 1.40, SettingsTestCase::ALLOWED_ENV_VARS no longer covers the environment-type variable, so a host-set ENVIRONMENT_TYPE is not unset between settings tests and can leak into cases that don't set it.
Observed in Vortex 1.40.2.
Details
ALLOWED_ENV_VARS is a list of prefixes:
const ALLOWED_ENV_VARS = [
// Service variables.
'DATABASE_', 'REDIS_', 'COMPOSE_', 'GITHUB_', 'PACKAGE_', 'DOCKER_',
// Vortex and Drupal variables.
'VORTEX_', 'DRUPAL_',
];
getRealEnvVarsFilteredNoValues() filters real environment variables with str_starts_with($key, $prefix) and unsets the matches during setEnvVars().
The old DRUPAL_ENVIRONMENT matched the DRUPAL_ prefix and was therefore cleared between tests. The de-namespaced ENVIRONMENT_TYPE matches none of the listed prefixes, so a value present in the real environment survives into EnvironmentSettingsTest cases that do not set it explicitly (for example testEnvironmentNoOverrides), making the environment-dependent assertions non-deterministic depending on the host/CI environment.
Suggested fix
Add the full variable name to the allow-list:
const ALLOWED_ENV_VARS = [
// Service variables.
'DATABASE_', 'REDIS_', 'COMPOSE_', 'GITHUB_', 'PACKAGE_', 'DOCKER_',
// Vortex and Drupal variables.
'VORTEX_', 'DRUPAL_',
'ENVIRONMENT_TYPE',
];
str_starts_with($key, 'ENVIRONMENT_TYPE') only matches ENVIRONMENT_TYPE itself (it does not match LAGOON_ENVIRONMENT_TYPE), so no unrelated variables are affected.
Summary
After the
DRUPAL_ENVIRONMENT->ENVIRONMENT_TYPErename in 1.40,SettingsTestCase::ALLOWED_ENV_VARSno longer covers the environment-type variable, so a host-setENVIRONMENT_TYPEis not unset between settings tests and can leak into cases that don't set it.Observed in Vortex
1.40.2.Details
ALLOWED_ENV_VARSis a list of prefixes:getRealEnvVarsFilteredNoValues()filters real environment variables withstr_starts_with($key, $prefix)and unsets the matches duringsetEnvVars().The old
DRUPAL_ENVIRONMENTmatched theDRUPAL_prefix and was therefore cleared between tests. The de-namespacedENVIRONMENT_TYPEmatches none of the listed prefixes, so a value present in the real environment survives intoEnvironmentSettingsTestcases that do not set it explicitly (for exampletestEnvironmentNoOverrides), making the environment-dependent assertions non-deterministic depending on the host/CI environment.Suggested fix
Add the full variable name to the allow-list:
str_starts_with($key, 'ENVIRONMENT_TYPE')only matchesENVIRONMENT_TYPEitself (it does not matchLAGOON_ENVIRONMENT_TYPE), so no unrelated variables are affected.