From cc67cfbc3d93ef11d04fcb60ee537ba6b6801a40 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Thu, 23 May 2024 10:43:03 -0400 Subject: [PATCH] Test edge case. --- tests/phpunit/src/Misc/TelemetryHelperTest.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/src/Misc/TelemetryHelperTest.php b/tests/phpunit/src/Misc/TelemetryHelperTest.php index 9c66da91c..2ced48679 100644 --- a/tests/phpunit/src/Misc/TelemetryHelperTest.php +++ b/tests/phpunit/src/Misc/TelemetryHelperTest.php @@ -14,7 +14,7 @@ class TelemetryHelperTest extends CommandTestBase { public function tearDown(): void { parent::tearDown(); - $envVars = []; + $envVars = ['AH_SITE_ENVIRONMENT' => 'test']; foreach ($this->providerTestEnvironmentProvider() as $args) { $envVars = array_merge($envVars, $args[1]); } @@ -55,12 +55,20 @@ public function testEnvironmentProvider(string $provider, array $envVars): void * Test the getEnvironmentProvider method when no environment provider is detected. */ public function testGetEnvironmentProviderWithoutAnyEnvSet(): void { - // Ensure no environment variables are set. - $providersList = TelemetryHelper::getProviders(); - TestBase::unsetEnvVars($providersList); - // Expect null since no provider environment variables are set. $this->assertNull(TelemetryHelper::getEnvironmentProvider()); } + /** + * Test the getEnvironmentProvider method when Acquia environment is detected. + */ + public function testGetEnvironmentProviderWithAcquia(): void { + TestBase::setEnvVars(['AH_SITE_ENVIRONMENT' => 'test']); + + // We need to make sure our mocked method is used. Depending on the implementation, + // this could involve setting it statically or using dependency injection. + // Expect 'acquia' to be returned since Acquia environment is mocked to be present. + $this->assertEquals('acquia', TelemetryHelper::getEnvironmentProvider()); + } + }