diff --git a/tests/phpunit/src/Application/ExceptionApplicationTest.php b/tests/phpunit/src/Application/ExceptionApplicationTest.php index 2118db99e..3fe3fd836 100644 --- a/tests/phpunit/src/Application/ExceptionApplicationTest.php +++ b/tests/phpunit/src/Application/ExceptionApplicationTest.php @@ -117,7 +117,7 @@ public function testMissingEnvironmentUuid(): void { */ public function testInvalidEnvironmentUuid(): void { $this->mockRequest('getAccount'); - $this->mockApplicationsRequest(); + $this->mockRequest('getApplications'); $this->setInput([ 'command' => 'log:tail', 'environmentId' => 'aoeuth.aoeu', @@ -142,7 +142,7 @@ public function testMissingApplicationUuid(): void { */ public function testInvalidApplicationUuid(): void { $this->mockRequest('getAccount'); - $this->mockApplicationsRequest(); + $this->mockRequest('getApplications'); $this->setInput([ 'applicationUuid' => 'aoeuthao', 'command' => 'ide:open', diff --git a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php index 222e98d84..76efca482 100644 --- a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php +++ b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php @@ -45,12 +45,12 @@ public function testNoEnvAvailableCommand(): void { * Test when no branch or tag available for the app. */ public function testNoVcsAvailableCommand(): void { - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $this->mockEnvironmentsRequest($applicationsResponse); + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); + $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid); $this->clientProphecy->request('get', - "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/code") + "/applications/{$applications[0]->uuid}/code") ->willReturn([]) ->shouldBeCalled(); diff --git a/tests/phpunit/src/Commands/App/LinkCommandTest.php b/tests/phpunit/src/Commands/App/LinkCommandTest.php index 3653a5030..cc0324570 100644 --- a/tests/phpunit/src/Commands/App/LinkCommandTest.php +++ b/tests/phpunit/src/Commands/App/LinkCommandTest.php @@ -19,7 +19,7 @@ protected function createCommand(): Command { } public function testLinkCommand(): void { - $applicationsResponse = $this->mockApplicationsRequest(); + $applications = $this->mockRequest('getApplications'); $this->mockApplicationRequest(); $inputs = [ @@ -30,7 +30,7 @@ public function testLinkCommand(): void { ]; $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->assertEquals($applicationsResponse->{'_embedded'}->items[0]->uuid, $this->datastoreAcli->get('cloud_app_uuid')); + $this->assertEquals($applications[self::$INPUT_DEFAULT_CHOICE]->uuid, $this->datastoreAcli->get('cloud_app_uuid')); $this->assertStringContainsString('There is no Cloud Platform application linked to', $output); $this->assertStringContainsString('Select a Cloud Platform application', $output); $this->assertStringContainsString('[0] Sample application 1', $output); diff --git a/tests/phpunit/src/Commands/App/LogTailCommandTest.php b/tests/phpunit/src/Commands/App/LogTailCommandTest.php index 2eb595b5c..71ddb48cd 100644 --- a/tests/phpunit/src/Commands/App/LogTailCommandTest.php +++ b/tests/phpunit/src/Commands/App/LogTailCommandTest.php @@ -19,9 +19,9 @@ protected function createCommand(): Command { public function testLogTailCommand(): void { - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $this->mockEnvironmentsRequest($applicationsResponse); + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->mockLogStreamRequest(); $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? diff --git a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php index 884481766..63b99d043 100644 --- a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php +++ b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php @@ -85,7 +85,7 @@ public function testEmailInfoForSubscriptionNoApps(): void { $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn($getDomainsResponse->_embedded->items); - $this->mockApplicationsRequest(); + $this->mockRequest('getApplications'); $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('You do not have access'); diff --git a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php index 8fee5e232..ce840b99f 100644 --- a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php @@ -28,17 +28,16 @@ public function testCloneRepo(): void { $this->acliRepoRoot = ''; $this->command = $this->createCommand(); // Client responses. - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $localMachineHelper = $this->mockReadIdePhpVersion(); $process = $this->mockProcess(); $dir = Path::join($this->vfsRoot->url(), 'empty-dir'); mkdir($dir); $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); - $this->mockExecuteGitClone($localMachineHelper, $selectedEnvironment, $process, $dir); - $this->mockExecuteGitCheckout($localMachineHelper, $selectedEnvironment->vcs->path, $dir, $process); + $this->mockExecuteGitClone($localMachineHelper, $environments[self::$INPUT_DEFAULT_CHOICE], $process, $dir); + $this->mockExecuteGitCheckout($localMachineHelper, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path, $dir, $process); $localMachineHelper->getFinder()->willReturn(new Finder()); $this->command->localMachineHelper = $localMachineHelper->reveal(); @@ -47,11 +46,11 @@ public function testCloneRepo(): void { // Would you like to clone a project into the current directory? 'y', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([ '--dir' => $dir, @@ -61,10 +60,9 @@ public function testCloneRepo(): void { } public function testPullCode(): void { - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); @@ -74,18 +72,18 @@ public function testPullCode(): void { $this->command->localMachineHelper = $localMachineHelper->reveal(); $process = $this->mockProcess(); - $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $selectedEnvironment->vcs->path); + $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path); $this->mockExecuteGitStatus(FALSE, $localMachineHelper, $this->projectDir); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([ @@ -102,10 +100,9 @@ public function testPullCode(): void { public function testWithScripts(): void { touch(Path::join($this->projectDir, 'composer.json')); - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); @@ -115,7 +112,7 @@ public function testWithScripts(): void { $this->command->localMachineHelper = $localMachineHelper->reveal(); $process = $this->mockProcess(); - $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $selectedEnvironment->vcs->path); + $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path); $this->mockExecuteGitStatus(FALSE, $localMachineHelper, $this->projectDir); $process = $this->mockProcess(); $this->mockExecuteComposerExists($localMachineHelper); @@ -128,11 +125,11 @@ public function testWithScripts(): void { // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([], $inputs); @@ -146,10 +143,9 @@ public function testWithScripts(): void { } public function testNoComposerJson(): void { - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); @@ -159,7 +155,7 @@ public function testNoComposerJson(): void { $this->command->localMachineHelper = $localMachineHelper->reveal(); $process = $this->mockProcess(); - $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $selectedEnvironment->vcs->path); + $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path); $this->mockExecuteGitStatus(FALSE, $localMachineHelper, $this->projectDir); $process = $this->mockProcess(); $this->mockExecuteDrushExists($localMachineHelper); @@ -170,11 +166,11 @@ public function testNoComposerJson(): void { // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([], $inputs); @@ -185,10 +181,9 @@ public function testNoComposerJson(): void { public function testNoComposer(): void { touch(Path::join($this->projectDir, 'composer.json')); - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); @@ -198,7 +193,7 @@ public function testNoComposer(): void { $this->command->localMachineHelper = $localMachineHelper->reveal(); $process = $this->mockProcess(); - $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $selectedEnvironment->vcs->path); + $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path); $this->mockExecuteGitStatus(FALSE, $localMachineHelper, $this->projectDir); $process = $this->mockProcess(); $localMachineHelper @@ -213,11 +208,11 @@ public function testNoComposer(): void { // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([], $inputs); @@ -230,10 +225,9 @@ public function testNoComposer(): void { public function testWithVendorDir(): void { touch(Path::join($this->projectDir, 'composer.json')); touch(Path::join($this->projectDir, 'vendor')); - $applicationsResponse = $this->mockApplicationsRequest(); - $this->mockApplicationRequest(); - $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); - $selectedEnvironment = $environmentsResponse->_embedded->items[0]; + $applications = $this->mockRequest('getApplications'); + $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); + $environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); @@ -243,7 +237,7 @@ public function testWithVendorDir(): void { $this->command->localMachineHelper = $localMachineHelper->reveal(); $process = $this->mockProcess(); - $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $selectedEnvironment->vcs->path); + $this->mockExecuteGitFetchAndCheckout($localMachineHelper, $process, $this->projectDir, $environments[self::$INPUT_DEFAULT_CHOICE]->vcs->path); $this->mockExecuteGitStatus(FALSE, $localMachineHelper, $this->projectDir); $process = $this->mockProcess(); $this->mockExecuteComposerExists($localMachineHelper); @@ -255,11 +249,11 @@ public function testWithVendorDir(): void { // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', // Select a Cloud Platform application: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? 'n', // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([], $inputs); @@ -318,7 +312,7 @@ public function testMatchPhpVersion(string $phpVersion): void { 'environmentId' => $environmentResponse->id, ], [ // Choose an Acquia environment: - 0, + self::$INPUT_DEFAULT_CHOICE, // Would you like to change the PHP version on this IDE to match the PHP version on ... ? 'n', ]);