From 2fd12510407e8ff659652de9b7e1d6b8352ea855 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 16 May 2024 16:15:23 -0700 Subject: [PATCH] telemetry --- .../src/Commands/TelemetryCommandTest.php | 104 ------------------ .../Commands/TelemetryDisableCommandTest.php | 29 ----- .../Commands/TelemetryEnableCommandTest.php | 31 ------ 3 files changed, 164 deletions(-) delete mode 100644 tests/phpunit/src/Commands/TelemetryCommandTest.php delete mode 100644 tests/phpunit/src/Commands/TelemetryDisableCommandTest.php delete mode 100644 tests/phpunit/src/Commands/TelemetryEnableCommandTest.php diff --git a/tests/phpunit/src/Commands/TelemetryCommandTest.php b/tests/phpunit/src/Commands/TelemetryCommandTest.php deleted file mode 100644 index b7ac1897a..000000000 --- a/tests/phpunit/src/Commands/TelemetryCommandTest.php +++ /dev/null @@ -1,104 +0,0 @@ -legacyAcliConfigFilepath = Path::join($this->dataDir, 'acquia-cli.json'); - $this->fs->remove($this->legacyAcliConfigFilepath); - } - - /**b - */ - protected function createCommand(): CommandBase { - return $this->injectCommand(TelemetryCommand::class); - } - - /** - * @group brokenProphecy - */ - public function testTelemetryCommand(): void { - $this->mockRequest('getAccount'); - $this->executeCommand(); - $output = $this->getDisplay(); - $this->assertStringContainsString('Telemetry has been enabled.', $output); - $this->executeCommand(); - $output = $this->getDisplay(); - $this->assertStringContainsString('Telemetry has been disabled.', $output); - } - - /** - * @return string[][] - */ - public function providerTestTelemetryPrompt(): array { - return [ - [ - // Would you like to share anonymous performance usage and data? - ['n'], - 'Ok, no data will be collected and shared with us.', - ], - ]; - } - - /** - * Tests telemetry prompt. - * - * @dataProvider providerTestTelemetryPrompt - * @param $message - */ - public function testTelemetryPrompt(array $inputs, mixed $message): void { - $this->cloudConfig = [DataStoreContract::SEND_TELEMETRY => NULL]; - $this->createMockConfigFiles(); - $this->createMockAcliConfigFile('a47ac10b-58cc-4372-a567-0e02b2c3d470'); - $this->createDataStores(); - $this->mockApplicationRequest(); - $this->command = $this->injectCommand(LinkCommand::class); - $this->executeCommand([], $inputs); - $output = $this->getDisplay(); - - $this->assertStringContainsString('Would you like to share anonymous performance usage and data?', $output); - $this->assertStringContainsString($message, $output); - } - - /** - * Opted out by default. - */ - public function testAmplitudeDisabled(): void { - $this->cloudConfig = [DataStoreContract::SEND_TELEMETRY => FALSE]; - $this->createMockConfigFiles(); - $this->executeCommand(); - - $this->assertEquals(0, $this->getStatusCode()); - - } - - public function testMigrateLegacyTelemetryPreference(): void { - $this->cloudConfig = [DataStoreContract::SEND_TELEMETRY => NULL]; - $this->createMockConfigFiles(); - $this->fs->remove($this->legacyAcliConfigFilepath); - $legacyAcliConfig = ['send_telemetry' => FALSE]; - $contents = json_encode($legacyAcliConfig); - $this->fs->dumpFile($this->legacyAcliConfigFilepath, $contents); - $this->executeCommand(); - - $this->assertEquals(0, $this->getStatusCode()); - $this->fs->remove($this->legacyAcliConfigFilepath); - } - -} diff --git a/tests/phpunit/src/Commands/TelemetryDisableCommandTest.php b/tests/phpunit/src/Commands/TelemetryDisableCommandTest.php deleted file mode 100644 index 25647d72d..000000000 --- a/tests/phpunit/src/Commands/TelemetryDisableCommandTest.php +++ /dev/null @@ -1,29 +0,0 @@ -injectCommand(TelemetryDisableCommand::class); - } - - public function testTelemetryDisableCommand(): void { - $this->executeCommand(); - $output = $this->getDisplay(); - $this->assertStringContainsString('Telemetry has been disabled.', $output); - - $settings = json_decode(file_get_contents($this->cloudConfigFilepath), TRUE); - $this->assertFalse($settings['send_telemetry']); - } - -} diff --git a/tests/phpunit/src/Commands/TelemetryEnableCommandTest.php b/tests/phpunit/src/Commands/TelemetryEnableCommandTest.php deleted file mode 100644 index 5cfc79953..000000000 --- a/tests/phpunit/src/Commands/TelemetryEnableCommandTest.php +++ /dev/null @@ -1,31 +0,0 @@ -injectCommand(TelemetryEnableCommand::class); - } - - public function testTelemetryEnableCommand(): void { - $this->executeCommand(); - $output = $this->getDisplay(); - $this->assertStringContainsString('Telemetry has been enabled.', $output); - - $settings = json_decode(file_get_contents($this->cloudConfigFilepath), TRUE); - $this->assertTrue($settings['send_telemetry']); - } - -}