From 923ea32eaca177b02f0d926a17770a8ed68e414e Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 16 May 2024 16:14:15 -0700 Subject: [PATCH] docs infer --- .../phpunit/src/Commands/DocsCommandTest.php | 114 ------------------ .../src/Commands/InferApplicationTest.php | 92 -------------- 2 files changed, 206 deletions(-) delete mode 100644 tests/phpunit/src/Commands/DocsCommandTest.php delete mode 100644 tests/phpunit/src/Commands/InferApplicationTest.php diff --git a/tests/phpunit/src/Commands/DocsCommandTest.php b/tests/phpunit/src/Commands/DocsCommandTest.php deleted file mode 100644 index cb7f3e1cc..000000000 --- a/tests/phpunit/src/Commands/DocsCommandTest.php +++ /dev/null @@ -1,114 +0,0 @@ -injectCommand(DocsCommand::class); - } - - /** - * @dataProvider providerTestDocsCommand - */ - public function testDocsCommand(int $input, string $expectedOutput): void { - $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->startBrowser(Argument::any())->shouldBeCalled(); - - $this->executeCommand([], [$input]); - $output = $this->getDisplay(); - $this->assertStringContainsString('Select the Acquia Product [Acquia CLI]:', $output); - $this->assertStringContainsString($expectedOutput, $output); - } - - /** - * @return array - */ - public function providerTestDocsCommand(): array { - return [ - [ - 0, - '[0 ] Acquia CLI', - ], - [ - 1, - '[1 ] Acquia CMS', - ], - [ - 2, - '[2 ] Acquia DAM Classic', - ], - [ - 3, - '[3 ] Acquia Migrate Accelerate', - ], - [ - 4, - '[4 ] BLT', - ], - [ - 5, - '[5 ] Campaign Factory', - ], - [ - 6, - '[6 ] Campaign Studio', - ], - [ - 7, - '[7 ] Cloud IDE', - ], - [ - 8, - '[8 ] Cloud Platform', - ], - [ - 9, - '[9 ] Code Studio', - ], - [ - 10, - '[10] Content Hub', - ], - [ - 11, - '[11] Customer Data Platform', - ], - [ - 12, - '[12] Edge', - ], - [ - 13, - '[13] Personalization', - ], - [ - 14, - '[14] Search', - ], - [ - 15, - '[15] Shield', - ], - [ - 16, - '[16] Site Factory', - ], - [ - 17, - '[17] Site Studio', - ], - ]; - } - -} diff --git a/tests/phpunit/src/Commands/InferApplicationTest.php b/tests/phpunit/src/Commands/InferApplicationTest.php deleted file mode 100644 index 24b3b2cdb..000000000 --- a/tests/phpunit/src/Commands/InferApplicationTest.php +++ /dev/null @@ -1,92 +0,0 @@ -injectCommand(LinkCommand::class); - } - - public function testInfer(): void { - $this->createMockGitConfigFile(); - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentResponse = $this->getMockEnvironmentResponse(); - // The searchApplicationEnvironmentsForGitUrl() method will only look - // for a match of the vcs url on the prod env. So, we mock a prod env. - $environmentResponse2 = $environmentResponse; - $environmentResponse2->flags->production = TRUE; - $this->clientProphecy->request('get', - "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments") - ->willReturn([$environmentResponse, $environmentResponse2]) - ->shouldBeCalled(); - - $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'y', - // Would you like to link the project at ... - 'y', - ]); - - $output = $this->getDisplay(); - - $this->assertStringContainsString('There is no Cloud Platform application linked to', $output); - $this->assertStringContainsString('Searching for a matching Cloud application...', $output); - $this->assertStringContainsString('Found a matching application!', $output); - $this->assertStringContainsString('The Cloud application Sample application 1 has been linked', $output); - } - - public function testInferFailure(): void { - $this->createMockGitConfigFile(); - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - - $environmentResponse = $this->getMockEnvironmentResponse(); - $this->clientProphecy->request('get', - "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments") - ->willReturn([$environmentResponse, $environmentResponse]) - ->shouldBeCalled(); - $this->clientProphecy->request('get', - "/applications/{$applicationsResponse->{'_embedded'}->items[1]->uuid}/environments") - ->willReturn([$environmentResponse, $environmentResponse]) - ->shouldBeCalled(); - - $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'y', - // Select a Cloud Platform application: - 0, - // Would you like to link the project at ... - 'y', - ]); - - $output = $this->getDisplay(); - - $this->assertStringContainsString('There is no Cloud Platform application linked to', $output); - $this->assertStringContainsString('Searching for a matching Cloud application...', $output); - $this->assertStringContainsString('Could not find a matching Cloud application.', $output); - $this->assertStringContainsString('The Cloud application Sample application 1 has been linked', $output); - } - - public function testInferInvalidGitConfig(): void { - $this->expectException(AcquiaCliException::class); - $this->executeCommand([], [ - 'y', - ]); - } - -}