From 83ae3ffce247a9fef31782e1bc453359e36af459 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Tue, 12 Dec 2023 14:58:06 -0800 Subject: [PATCH] check prophecies in test teardown --- tests/phpunit/src/CommandTestBase.php | 7 +++ .../src/Commands/Acsf/AcsfApiCommandTest.php | 8 +-- .../src/Commands/Api/ApiCommandTest.php | 37 ++++++------ .../src/Commands/App/AppOpenCommandTest.php | 4 +- .../src/Commands/App/AppVcsInfoTest.php | 10 ++-- .../src/Commands/App/LinkCommandTest.php | 3 + .../src/Commands/App/LogTailCommandTest.php | 4 +- .../src/Commands/App/NewCommandTest.php | 4 +- .../App/NewFromDrupal7CommandTest.php | 2 +- .../src/Commands/App/TaskWaitCommandTest.php | 8 +-- .../Archive/ArchiveExporterCommandTest.php | 2 +- .../Commands/Auth/AuthLoginCommandTest.php | 1 + .../src/Commands/ClearCacheCommandTest.php | 2 +- .../CodeStudioPhpVersionCommandTest.php | 4 +- .../CodeStudioPipelinesMigrateCommandTest.php | 1 + .../CodeStudioWizardCommandTest.php | 8 ++- .../phpunit/src/Commands/CommandBaseTest.php | 3 +- .../ConfigurePlatformEmailCommandTest.php | 14 ++--- .../Commands/Env/EnvCertCreateCommandTest.php | 5 +- .../src/Commands/Env/EnvCreateCommandTest.php | 7 +++ .../src/Commands/Env/EnvDeleteCommandTest.php | 5 +- .../src/Commands/Ide/IdeCreateCommandTest.php | 5 +- .../src/Commands/Ide/IdeDeleteCommandTest.php | 5 +- .../src/Commands/Ide/IdeInfoCommandTest.php | 5 +- .../Commands/Ide/IdeListCommandMineTest.php | 2 +- .../src/Commands/Ide/IdeListCommandTest.php | 10 +++- .../src/Commands/Ide/IdeOpenCommandTest.php | 5 +- .../Commands/Ide/IdePhpVersionCommandTest.php | 2 +- .../Ide/IdeServiceRestartCommandTest.php | 5 +- .../Ide/IdeServiceStartCommandTest.php | 5 +- .../Ide/IdeServiceStopCommandTest.php | 5 +- .../src/Commands/Ide/IdeShareCommandTest.php | 4 +- .../Ide/IdeXdebugToggleCommandTest.php | 2 +- .../IdeWizardCreateSshKeyCommandTest.php | 3 + .../IdeWizardDeleteSshKeyCommandTest.php | 1 - .../src/Commands/InferApplicationTest.php | 2 - .../src/Commands/Pull/PullCodeCommandTest.php | 14 ++--- .../Commands/Pull/PullDatabaseCommandTest.php | 60 ++++++++++++------- .../Commands/Pull/PullFilesCommandTest.php | 4 +- .../Commands/Pull/PullScriptsCommandTest.php | 2 +- .../Commands/Push/PushArtifactCommandTest.php | 14 ++--- .../src/Commands/Push/PushCodeCommandTest.php | 2 +- .../Commands/Push/PushDatabaseCommandTest.php | 2 +- .../Commands/Push/PushFilesCommandTest.php | 6 +- .../Remote/AliasesDownloadCommandTest.php | 2 +- .../Remote/AliasesListCommandTest.php | 2 +- .../src/Commands/Remote/DrushCommandTest.php | 2 +- .../src/Commands/Remote/SshCommandTest.php | 2 +- .../Commands/Ssh/SshKeyCreateCommandTest.php | 1 + .../Ssh/SshKeyCreateUploadCommandTest.php | 2 +- .../Commands/Ssh/SshKeyDeleteCommandTest.php | 2 +- .../Commands/Ssh/SshKeyInfoCommandTest.php | 2 +- .../Commands/Ssh/SshKeyListCommandTest.php | 2 +- .../Commands/Ssh/SshKeyUploadCommandTest.php | 2 +- .../src/Commands/TelemetryCommandTest.php | 7 ++- tests/phpunit/src/Commands/WizardTestBase.php | 2 +- 56 files changed, 206 insertions(+), 126 deletions(-) diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index 374bc1c0c..5ff444de6 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -62,6 +62,13 @@ protected function setUp(): void { $this->printTestName(); } + protected function tearDown(): void { + parent::tearDown(); + if (!in_array('brokenProphecy', $this->getGroups())) { + $this->prophet->checkPredictions(); + } + } + protected function setCommand(CommandBase $command): void { $this->command = $command; } diff --git a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php index b81fb818b..2e555524b 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php @@ -49,7 +49,7 @@ public function testAcsfCommandExecutionForHttpPostWithMultipleDataTypes(): void ]); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); } @@ -64,7 +64,7 @@ public function testAcsfCommandExecutionBool(): void { ]); // Assert. - $this->prophet->checkPredictions(); + } public function testAcsfCommandExecutionForHttpGet(): void { @@ -77,7 +77,7 @@ public function testAcsfCommandExecutionForHttpGet(): void { $this->executeCommand(['--limit' => '1']); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertNotNull($output); $this->assertJson($output); @@ -112,7 +112,7 @@ public function testAcsfCommandExecutionForHttpGetMultiple(mixed $method, mixed $this->executeCommand($arguments, []); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertNotNull($output); $this->assertJson($output); diff --git a/tests/phpunit/src/Commands/Api/ApiCommandTest.php b/tests/phpunit/src/Commands/Api/ApiCommandTest.php index 704cb697a..5bd9b1910 100644 --- a/tests/phpunit/src/Commands/Api/ApiCommandTest.php +++ b/tests/phpunit/src/Commands/Api/ApiCommandTest.php @@ -29,6 +29,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(ApiBaseCommand::class); } + /** + * @group brokenProphecy + */ public function testArgumentsInteraction(): void { $this->command = $this->getApiCommandByName('api:environments:log-download'); $this->executeCommand([], [ @@ -94,7 +97,7 @@ public function testApiCommandErrorResponse(): void { ]); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertJson($output); $this->assertStringContainsString($mockBody->message, $output); @@ -111,7 +114,7 @@ public function testApiCommandExecutionForHttpGet(): void { $this->executeCommand(['--limit' => '1']); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertNotNull($output); $this->assertJson($output); @@ -120,6 +123,9 @@ public function testApiCommandExecutionForHttpGet(): void { $this->assertArrayHasKey('uuid', $contents[0]); } + /** + * @group brokenProphecy + */ public function testObjectParam(): void { $this->mockRequest('putEnvironmentCloudActions', '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->command = $this->getApiCommandByName('api:environments:cloud-actions-update'); @@ -145,7 +151,7 @@ public function testInferApplicationUuidArgument(): void { ]); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Inferring Cloud Application UUID for this command since none was provided...', $output); $this->assertStringContainsString('Set application uuid to ' . $application->uuid, $output); @@ -195,7 +201,7 @@ public function testConvertApplicationAliasToUuidArgument(bool $support): void { ]); // Assert. - $this->prophet->checkPredictions(); + $this->getDisplay(); $this->assertEquals(0, $this->getStatusCode()); } @@ -209,7 +215,7 @@ public function testConvertInvalidApplicationAliasToUuidArgument(): void { $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('No applications match the alias *:invalidalias'); $this->executeCommand(['applicationUuid' => $alias], []); - $this->prophet->checkPredictions(); + } /** @@ -228,7 +234,6 @@ public function testConvertNonUniqueApplicationAliasToUuidArgument(): void { $output = $this->getDisplay(); $this->assertStringContainsString('Use a unique application alias: devcloud:devcloud2, devcloud:devcloud2', $output); - $this->prophet->checkPredictions(); } public function testConvertApplicationAliasWithRealmToUuidArgument(): void { @@ -239,7 +244,7 @@ public function testConvertApplicationAliasWithRealmToUuidArgument(): void { $this->command = $this->getApiCommandByName('api:applications:find'); $alias = 'devcloud:devcloud2'; $this->executeCommand(['applicationUuid' => $alias], []); - $this->prophet->checkPredictions(); + } /** @@ -268,7 +273,7 @@ public function testConvertEnvironmentAliasToUuidArgument(): void { ]); // Assert. - $this->prophet->checkPredictions(); + $this->getDisplay(); $this->assertEquals(0, $this->getStatusCode()); } @@ -287,7 +292,7 @@ public function testConvertInvalidEnvironmentAliasToUuidArgument(): void { $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('{environmentId} must be a valid UUID or site alias.'); $this->executeCommand(['environmentId' => $alias], []); - $this->prophet->checkPredictions(); + } public function testApiCommandExecutionForHttpPost(): void { @@ -301,7 +306,7 @@ public function testApiCommandExecutionForHttpPost(): void { $this->executeCommand($mockRequestArgs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertNotNull($output); $this->assertJson($output); @@ -329,7 +334,7 @@ public function testApiCommandExecutionForHttpPut(): void { $this->executeCommand($args); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertNotNull($output); $this->assertJson($output); @@ -424,14 +429,11 @@ public function testGetApplicationUuidFromBltYml(): void { $bltConfigFilePath = Path::join($this->projectDir, 'blt', 'blt.yml'); $this->fs->dumpFile($bltConfigFilePath, Yaml::dump(['cloud' => ['appId' => $mockBody->uuid]])); $this->executeCommand(); - $this->prophet->checkPredictions(); + $this->getDisplay(); $this->fs->remove($bltConfigFilePath); } - /** - * Test of deletion of the user from organization by user uuid. - */ public function testOrganizationMemberDeleteByUserUuid(): void { $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; $memberUuid = '26c4af83-545b-45cb-b165-d537adc9e0b4'; @@ -446,7 +448,6 @@ public function testOrganizationMemberDeleteByUserUuid(): void { ], ); - $this->prophet->checkPredictions(); $output = $this->getDisplay(); $this->assertEquals(0, $this->getStatusCode()); $this->assertStringContainsString("Organization member removed", $output); @@ -473,12 +474,14 @@ public function testOrganizationMemberDeleteByUserEmail(): void { ], ); - $this->prophet->checkPredictions(); $output = $this->getDisplay(); $this->assertEquals(0, $this->getStatusCode()); $this->assertStringContainsString("Organization member removed", $output); } + /** + * @group brokenProphecy + */ public function testOrganizationMemberDeleteInvalidEmail(): void { $membersResponse = $this->getMockResponseFromSpec('/organizations/{organizationUuid}/members', 'get', 200); $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; diff --git a/tests/phpunit/src/Commands/App/AppOpenCommandTest.php b/tests/phpunit/src/Commands/App/AppOpenCommandTest.php index ef31dc475..98f5bbd6e 100644 --- a/tests/phpunit/src/Commands/App/AppOpenCommandTest.php +++ b/tests/phpunit/src/Commands/App/AppOpenCommandTest.php @@ -25,9 +25,11 @@ public function testAppOpenCommand(): void { $localMachineHelper->isBrowserAvailable()->willReturn(TRUE); $this->mockRequest('getApplicationByUuid', $applicationUuid); $this->executeCommand(['applicationUuid' => $applicationUuid]); - $this->prophet->checkPredictions(); } + /** + * @group brokenProphecy + */ public function testAppOpenNoBrowser(): void { $applicationUuid = 'a47ac10b-58cc-4372-a567-0e02b2c3d470'; $localMachineHelper = $this->mockLocalMachineHelper(); diff --git a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php index 29c693365..9c65502b7 100644 --- a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php +++ b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php @@ -19,7 +19,7 @@ protected function createCommand(): CommandBase { } /** - * Test when no environment available for the app. + * @group brokenProphecy */ public function testNoEnvAvailableCommand(): void { $applications = $this->mockRequest('getApplications'); @@ -42,7 +42,7 @@ public function testNoEnvAvailableCommand(): void { } /** - * Test when no branch or tag available for the app. + * @group brokenProphecy */ public function testNoVcsAvailableCommand(): void { $applications = $this->mockRequest('getApplications'); @@ -64,7 +64,7 @@ public function testNoVcsAvailableCommand(): void { } /** - * Test the list of the VCS details of the application. + * @group brokenProphecy */ public function testShowVcsListCommand(): void { $applications = $this->mockRequest('getApplications'); @@ -96,7 +96,7 @@ public function testShowVcsListCommand(): void { } /** - * Test the list of deployed VCS but no deployed VCS available. + * @group brokenProphecy */ public function testNoDeployedVcs(): void { $applications = $this->mockRequest('getApplications'); @@ -124,7 +124,7 @@ public function testNoDeployedVcs(): void { } /** - * Test the list of the only deployed VCS. + * @group brokenProphecy */ public function testListOnlyDeployedVcs(): void { $applications = $this->mockRequest('getApplications'); diff --git a/tests/phpunit/src/Commands/App/LinkCommandTest.php b/tests/phpunit/src/Commands/App/LinkCommandTest.php index de99b95c2..25604aaa7 100644 --- a/tests/phpunit/src/Commands/App/LinkCommandTest.php +++ b/tests/phpunit/src/Commands/App/LinkCommandTest.php @@ -47,6 +47,9 @@ public function testLinkCommandAlreadyLinked(): void { $this->assertEquals(1, $this->getStatusCode()); } + /** + * @group brokenProphecy + */ public function testLinkCommandInvalidDir(): void { $this->mockRequest('getApplications'); $this->command->setProjectDir(''); diff --git a/tests/phpunit/src/Commands/App/LogTailCommandTest.php b/tests/phpunit/src/Commands/App/LogTailCommandTest.php index fdb088de3..60dffec56 100644 --- a/tests/phpunit/src/Commands/App/LogTailCommandTest.php +++ b/tests/phpunit/src/Commands/App/LogTailCommandTest.php @@ -34,7 +34,7 @@ public function testLogTailCommand(): void { ]); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString('[0] Sample application 1', $output); @@ -52,7 +52,7 @@ public function testLogTailCommandWithEnvArg(): void { ); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Apache request', $output); $this->assertStringContainsString('Drupal request', $output); diff --git a/tests/phpunit/src/Commands/App/NewCommandTest.php b/tests/phpunit/src/Commands/App/NewCommandTest.php index fd04dc276..01c22bdf9 100644 --- a/tests/phpunit/src/Commands/App/NewCommandTest.php +++ b/tests/phpunit/src/Commands/App/NewCommandTest.php @@ -77,7 +77,7 @@ public function testNewDrupalCommand(array $package, string $directory = 'drupal $this->executeCommand([ 'directory' => $directory, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Acquia recommends most customers use acquia/drupal-recommended-project to setup a Drupal project', $output); $this->assertStringContainsString('Choose a starting project', $output); @@ -117,7 +117,7 @@ public function testNewNextJSAppCommand(array $package, string $directory = 'nex $this->executeCommand([ 'directory' => $directory, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('acquia/next-acms is a starter template for building a headless site', $output); $this->assertStringContainsString('Choose a starting project', $output); diff --git a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php index 16bfa2bec..826dd7ef5 100644 --- a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php +++ b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php @@ -107,7 +107,7 @@ public function testNewFromDrupal7Command(string $extensions_json, string $recom '--recommendations' => $recommendations_json, '--stored-analysis' => $extensions_json, ]); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Found Drupal 7 site', $output); $this->assertStringContainsString('Computing recommendations', $output); diff --git a/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php b/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php index 10dcdd34b..9c7ffbcec 100644 --- a/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php +++ b/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php @@ -28,7 +28,7 @@ public function testTaskWaitCommand(string $notification): void { $this->executeCommand([ 'notification-uuid' => $notification, ]); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); self::assertStringContainsString(' [OK] The task with notification uuid 1bd3487e-71d1-4fca-a2d9-5f969b3d35c1 completed', $output); $this->assertStringContainsString('Progress: 100', $output); @@ -51,7 +51,7 @@ function ($response): void { $this->executeCommand([ 'notification-uuid' => $notificationUuid, ]); - $this->prophet->checkPredictions(); + self::assertStringContainsString(' [ERROR] The task with notification uuid 1bd3487e-71d1-4fca-a2d9-5f969b3d35c1 failed', $this->getDisplay()); $this->assertEquals(Command::FAILURE, $this->getStatusCode()); } @@ -93,7 +93,7 @@ public function testTaskWaitCommandWithEmptyJson(): void { $this->executeCommand(['notification-uuid' => '{}']); // Assert. - $this->prophet->checkPredictions(); + } public function testTaskWaitCommandWithInvalidUrl(): void { @@ -102,7 +102,7 @@ public function testTaskWaitCommandWithInvalidUrl(): void { $this->executeCommand(['notification-uuid' => 'https://cloud.acquia.com/api/notifications/foo']); // Assert. - $this->prophet->checkPredictions(); + } /** diff --git a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php index 7850292ae..28d048240 100644 --- a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php +++ b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php @@ -50,7 +50,7 @@ public function testArchiveExport(): void { $this->executeCommand([ 'destination-dir' => $destinationDir, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); self::assertStringContainsString('An archive of your Drupal application was created at', $output); diff --git a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php index aadabdf26..97873fa64 100644 --- a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php +++ b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php @@ -38,6 +38,7 @@ public function providerTestAuthLoginCommand(): Generator { /** * @dataProvider providerTestAuthLoginCommand + * @group brokenProphecy */ public function testAuthLoginCommand(bool $machineIsAuthenticated, bool $assertCloudPrompts, array $inputs, array $args, string $outputToAssert): void { $this->mockRequest('getAccountToken', $this->key); diff --git a/tests/phpunit/src/Commands/ClearCacheCommandTest.php b/tests/phpunit/src/Commands/ClearCacheCommandTest.php index 43144deb8..148d388fc 100644 --- a/tests/phpunit/src/Commands/ClearCacheCommandTest.php +++ b/tests/phpunit/src/Commands/ClearCacheCommandTest.php @@ -51,7 +51,7 @@ public function testAliasesAreCached(): void { $this->executeCommand($args, $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertEquals(0, $this->getStatusCode()); } diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php index 8115790d0..a345d6022 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php @@ -111,7 +111,7 @@ public function testPhpVersionAddFail(): void { } /** - * Test for successful PHP version add. + * @group brokenProphecy */ public function testPhpVersionAdd(): void { $this->mockApplicationRequest(); @@ -184,7 +184,7 @@ public function testPhpVersionUpdateFail(): void { } /** - * Test for successful PHP version update. + * @group brokenProphecy */ public function testPhpVersionUpdate(): void { $this->mockApplicationRequest(); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php index 121528255..1c5a0e5a1 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php @@ -76,6 +76,7 @@ public function providerTestCommand(): array { * @param $mockedGitlabProjects * @param $args * @param $inputs + * @group brokenProphecy */ public function testCommand(mixed $mockedGitlabProjects, mixed $inputs, mixed $args): void { copy( diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index 8018891ab..40d475eaa 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -261,10 +261,13 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a $this->executeCommand($args, $inputs); // Assertions. - $this->prophet->checkPredictions(); + $this->assertEquals(0, $this->getStatusCode()); } + /** + * @group brokenProphecy + */ public function testInvalidGitLabCredentials(): void { $localMachineHelper = $this->mockLocalMachineHelper(); $this->mockExecuteGlabExists($localMachineHelper); @@ -279,6 +282,9 @@ public function testInvalidGitLabCredentials(): void { ]); } + /** + * @group brokenProphecy + */ public function testMissingGitLabCredentials(): void { $localMachineHelper = $this->mockLocalMachineHelper(); $this->mockExecuteGlabExists($localMachineHelper); diff --git a/tests/phpunit/src/Commands/CommandBaseTest.php b/tests/phpunit/src/Commands/CommandBaseTest.php index 8d06b8491..85a295d74 100644 --- a/tests/phpunit/src/Commands/CommandBaseTest.php +++ b/tests/phpunit/src/Commands/CommandBaseTest.php @@ -42,7 +42,7 @@ public function testCloudAppFromLocalConfig(): void { $this->mockRequest('getApplicationIdes', 'a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->createMockAcliConfigFile('a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->executeCommand(); - $this->prophet->checkPredictions(); + } /** @@ -57,6 +57,7 @@ public function providerTestCloudAppUuidArg(): array { /** * @dataProvider providerTestCloudAppUuidArg + * @group brokenProphecy */ public function testCloudAppUuidArg(string $uuid): void { $this->mockApplicationRequest(); diff --git a/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php b/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php index 0974f8c36..632f28361 100644 --- a/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php +++ b/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php @@ -290,7 +290,7 @@ public function testConfigurePlatformEmail(mixed $baseDomain, mixed $fileDumpFor $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->prophet->checkPredictions(); + $this->assertEquals($expectedExitCode, $this->getStatusCode()); foreach ($expectedText as $text) { $this->assertStringContainsString($text, $output); @@ -370,7 +370,7 @@ public function testConfigurePlatformEmailWithMultipleAppsAndEnvs(): void { $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->prophet->checkPredictions(); + $this->assertEquals(0, $this->getStatusCode()); $this->assertStringContainsString("You're all set to start using Platform Email!", $output); @@ -426,7 +426,7 @@ public function testConfigurePlatformEmailNoApps(): void { $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->prophet->checkPredictions(); + $this->assertStringNotContainsString("You're all set to start using Platform Email!", $output); } @@ -463,8 +463,6 @@ public function testConfigurePlatformEmailWithNoDomainMatch(): void { $this->expectExceptionMessage('Could not find domain'); $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); - } public function testConfigurePlatformEmailWithErrorRetrievingDomainHealth(): void { @@ -503,8 +501,6 @@ public function testConfigurePlatformEmailWithErrorRetrievingDomainHealth(): voi $this->expectExceptionMessage('Could not retrieve DNS records for this domain'); $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); - } /** @@ -567,7 +563,7 @@ public function testConfigurePlatformEmailJsonOutput(): void { $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->prophet->checkPredictions(); + $this->assertEquals('0', $this->getStatusCode()); $this->assertStringContainsString('all set', $output); } @@ -618,7 +614,7 @@ public function testConfigurePlatformEmailWithAlreadyEnabledEnvs(mixed $baseDoma $this->executeCommand([], $inputs); $output = $this->getDisplay(); - $this->prophet->checkPredictions(); + $this->assertEquals($expectedExitCode, $this->getStatusCode()); foreach ($expectedText as $text) { $this->assertStringContainsString($text, $output); diff --git a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php index 8315e864c..e8e2178bd 100644 --- a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php @@ -14,6 +14,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(EnvCertCreateCommand::class); } + /** + * @group brokenProphecy + */ public function testCreateCert(): void { $applicationsResponse = $this->mockApplicationsRequest(); $this->mockApplicationRequest(); @@ -60,7 +63,7 @@ public function testCreateCert(): void { 0, ] ); - $this->prophet->checkPredictions(); + } } diff --git a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php index b7e556e4f..25f551f82 100644 --- a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php @@ -87,6 +87,7 @@ public function providerTestCreateCde(): array { /** * @dataProvider providerTestCreateCde + * @group brokenProphecy */ public function testCreateCde(mixed $args, mixed $input): void { $domain = $this->setupCdeTest(self::$validLabel); @@ -105,6 +106,9 @@ public function testCreateCde(mixed $args, mixed $input): void { $this->assertStringContainsString("Your CDE URL: $domain", $output); } + /** + * @group brokenProphecy + */ public function testCreateCdeNonUniqueLabel(): void { $label = 'Dev'; $this->setupCdeTest($label); @@ -120,6 +124,9 @@ public function testCreateCdeNonUniqueLabel(): void { ); } + /** + * @group brokenProphecy + */ public function testCreateCdeInvalidTag(): void { $this->setupCdeTest(self::$validLabel); diff --git a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php index ab06015eb..997222e7b 100644 --- a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php @@ -32,6 +32,7 @@ public function providerTestDeleteCde(): array { /** * @dataProvider providerTestDeleteCde + * @group brokenProphecy */ public function testDeleteCde(mixed $environmentId): void { $applicationsResponse = $this->mockApplicationsRequest(); @@ -80,7 +81,7 @@ public function testDeleteCde(mixed $environmentId): void { } /** - * Tests the case when no CDE available for application. + * @group brokenProphecy */ public function testNoExistingCDEEnvironment(): void { $applicationsResponse = $this->mockApplicationsRequest(); @@ -101,7 +102,7 @@ public function testNoExistingCDEEnvironment(): void { } /** - * Tests the case when multiple CDE available for application. + * @group brokenProphecy */ public function testNoEnvironmentArgumentPassed(): void { $applications = $this->mockRequest('getApplications'); diff --git a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php index f244ad416..85739ca52 100644 --- a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php @@ -15,6 +15,9 @@ */ class IdeCreateCommandTest extends CommandTestBase { + /** + * @group brokenProphecy + */ public function testCreate(): void { $applicationsResponse = $this->mockRequest('getApplications'); $applicationUuid = $applicationsResponse[self::$INPUT_DEFAULT_CHOICE]->uuid; @@ -47,7 +50,7 @@ public function testCreate(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString(' [0] Sample application 1', $output); diff --git a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php index 0632364ce..68ccc584e 100644 --- a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php @@ -31,6 +31,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(IdeDeleteCommand::class); } + /** + * @group brokenProphecy + */ public function testIdeDeleteCommand(): void { $applications = $this->mockRequest('getApplications'); $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); @@ -58,7 +61,7 @@ public function testIdeDeleteCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('The Cloud IDE is being deleted.', $output); } diff --git a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php index 91cea5af2..771bc2f96 100644 --- a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php @@ -17,6 +17,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(IdeInfoCommand::class); } + /** + * @group brokenProphecy + */ public function testIdeInfoCommand(): void { $applications = $this->mockRequest('getApplications'); $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); @@ -35,7 +38,7 @@ public function testIdeInfoCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString('[0] Sample application 1', $output); diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php index cb70b2673..c7c69ae1a 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php @@ -41,7 +41,7 @@ public function testIdeListMineCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('IDE Label 1', $output); $this->assertStringContainsString('UUID: 9a83c081-ef78-4dbd-8852-11cc3eb248f7', $output); diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php index afa560e53..3ee4d87a6 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php @@ -17,6 +17,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(IdeListCommand::class); } + /** + * @group brokenProphecy + */ public function testIdeListCommand(): void { $applications = $this->mockRequest('getApplications'); /** @var \AcquiaCloudApi\Response\ApplicationResponse $application */ @@ -33,7 +36,7 @@ public function testIdeListCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString('[0] Sample application 1', $output); @@ -46,6 +49,9 @@ public function testIdeListCommand(): void { $this->assertStringContainsString('IDE URL: https://feea197a-9503-4441-9f49-b4d420b0ecf8.ides.acquia.com', $output); } + /** + * @group brokenProphecy + */ public function testIdeListEmptyCommand(): void { $this->mockRequest('getApplications'); $this->mockApplicationRequest(); @@ -65,7 +71,7 @@ public function testIdeListEmptyCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString('[0] Sample application 1', $output); diff --git a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php index f2532a169..d0417bb92 100644 --- a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php @@ -17,6 +17,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(IdeOpenCommand::class); } + /** + * @group brokenProphecy + */ public function testIdeOpenCommand(): void { $applications = $this->mockRequest('getApplications'); $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); @@ -38,7 +41,7 @@ public function testIdeOpenCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); $this->assertStringContainsString('[0] Sample application 1', $output); diff --git a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php index 79316b719..f7e0337fd 100644 --- a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php @@ -54,7 +54,7 @@ public function testIdePhpVersionCommand(string $version): void { $this->executeCommand([ 'version' => $version, ], []); - $this->prophet->checkPredictions(); + } /** diff --git a/tests/phpunit/src/Commands/Ide/IdeServiceRestartCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeServiceRestartCommandTest.php index 641ba5f41..155bfc601 100644 --- a/tests/phpunit/src/Commands/Ide/IdeServiceRestartCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeServiceRestartCommandTest.php @@ -27,11 +27,14 @@ public function testIdeServiceRestartCommand(): void { $this->executeCommand(['service' => 'php'], []); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Restarted php', $output); } + /** + * @group brokenProphecy + */ public function testIdeServiceRestartCommandInvalid(): void { $localMachineHelper = $this->mockLocalMachineHelper(); $this->mockRestartPhp($localMachineHelper); diff --git a/tests/phpunit/src/Commands/Ide/IdeServiceStartCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeServiceStartCommandTest.php index 7b7fd26d5..d82c25d4a 100644 --- a/tests/phpunit/src/Commands/Ide/IdeServiceStartCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeServiceStartCommandTest.php @@ -27,11 +27,14 @@ public function testIdeServiceStartCommand(): void { $this->executeCommand(['service' => 'php'], []); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Starting php', $output); } + /** + * @group brokenProphecy + */ public function testIdeServiceStartCommandInvalid(): void { $localMachineHelper = $this->mockLocalMachineHelper(); $this->mockStartPhp($localMachineHelper); diff --git a/tests/phpunit/src/Commands/Ide/IdeServiceStopCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeServiceStopCommandTest.php index a0af5d510..5690e89c8 100644 --- a/tests/phpunit/src/Commands/Ide/IdeServiceStopCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeServiceStopCommandTest.php @@ -27,11 +27,14 @@ public function testIdeServiceStopCommand(): void { $this->executeCommand(['service' => 'php'], []); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Stopping php', $output); } + /** + * @group brokenProphecy + */ public function testIdeServiceStopCommandInvalid(): void { $localMachineHelper = $this->mockLocalMachineHelper(); $this->mockStopPhp($localMachineHelper); diff --git a/tests/phpunit/src/Commands/Ide/IdeShareCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeShareCommandTest.php index 035b5e680..aa9cfe3ee 100644 --- a/tests/phpunit/src/Commands/Ide/IdeShareCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeShareCommandTest.php @@ -46,7 +46,7 @@ public function testIdeShareCommand(): void { $this->executeCommand(); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Your IDE Share URL: ', $output); $this->assertStringContainsString($this->shareCode, $output); @@ -58,7 +58,7 @@ public function testIdeShareRegenerateCommand(): void { $this->executeCommand(['--regenerate' => TRUE], []); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Your IDE Share URL: ', $output); $this->assertStringNotContainsString($this->shareCode, $output); diff --git a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php index b7e000997..976281515 100644 --- a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php @@ -59,7 +59,7 @@ public function providerTestXdebugCommandEnable(): array { public function testXdebugCommandEnable(mixed $phpVersion): void { $this->setUpXdebug($phpVersion); $this->executeCommand(); - $this->prophet->checkPredictions(); + $this->assertFileExists($this->xdebugFilePath); $this->assertStringContainsString('zend_extension=xdebug.so', file_get_contents($this->xdebugFilePath)); $this->assertStringNotContainsString(';zend_extension=xdebug.so', file_get_contents($this->xdebugFilePath)); diff --git a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php index 8eca18579..14312f52a 100644 --- a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php @@ -44,6 +44,9 @@ public function testCreate(): void { parent::runTestCreate(); } + /** + * @group brokenProphecy + */ public function testSshKeyAlreadyUploaded(): void { parent::runTestSshKeyAlreadyUploaded(); } diff --git a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php index 50ec65d2a..be5c4e5fd 100644 --- a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php @@ -31,7 +31,6 @@ public function testDelete(): void { // Run it! $this->executeCommand([]); - $this->prophet->checkPredictions(); $this->assertFileDoesNotExist($this->sshDir . '/' . $sshKeyFilename); } diff --git a/tests/phpunit/src/Commands/InferApplicationTest.php b/tests/phpunit/src/Commands/InferApplicationTest.php index 8ba4f6a63..24b3b2cdb 100644 --- a/tests/phpunit/src/Commands/InferApplicationTest.php +++ b/tests/phpunit/src/Commands/InferApplicationTest.php @@ -42,7 +42,6 @@ public function testInfer(): void { 'y', ]); - $this->prophet->checkPredictions(); $output = $this->getDisplay(); $this->assertStringContainsString('There is no Cloud Platform application linked to', $output); @@ -75,7 +74,6 @@ public function testInferFailure(): void { 'y', ]); - $this->prophet->checkPredictions(); $output = $this->getDisplay(); $this->assertStringContainsString('There is no Cloud Platform application linked to', $output); diff --git a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php index f2ae46782..02d6d683d 100644 --- a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php @@ -52,7 +52,7 @@ public function testCloneRepo(): void { '--dir' => $dir, '--no-scripts' => TRUE, ], $inputs); - $this->prophet->checkPredictions(); + } public function testPullCode(): void { @@ -71,7 +71,7 @@ public function testPullCode(): void { $this->executeCommand([ '--no-scripts' => TRUE, ], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -101,7 +101,7 @@ public function testWithScripts(): void { $this->mockExecuteDrushCacheRebuild($localMachineHelper, $process); $this->executeCommand([], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -128,7 +128,7 @@ public function testNoComposerJson(): void { $this->mockExecuteDrushCacheRebuild($localMachineHelper, $process); $this->executeCommand([], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('composer.json file not found. Skipping composer install.', $output); } @@ -158,7 +158,7 @@ public function testNoComposer(): void { $this->mockExecuteDrushCacheRebuild($localMachineHelper, $process); $this->executeCommand([], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Composer not found. Skipping composer install.', $output); @@ -187,7 +187,7 @@ public function testWithVendorDir(): void { $this->mockExecuteDrushCacheRebuild($localMachineHelper, $process); $this->executeCommand([], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Composer dependencies already installed. Skipping composer install.', $output); @@ -245,7 +245,7 @@ public function testMatchPhpVersion(string $phpVersion): void { // Would you like to change the PHP version on this IDE to match the PHP version on ... ? 'n', ]); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); IdeHelper::unsetCloudIdeEnvVars(); $message = "Would you like to change the PHP version on this IDE to match the PHP version on the {$environmentResponse->label} ({$environmentResponse->configuration->php->version}) environment?"; diff --git a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php index 8bcaf6a02..dfbf9c8b6 100644 --- a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php @@ -77,7 +77,7 @@ public function testPullDatabases(): void { $this->executeCommand([ '--no-scripts' => TRUE, ], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -115,14 +115,14 @@ public function testPullDatabaseNoPv(): void { $this->executeCommand([ '--no-scripts' => TRUE, ], self::inputChooseEnvironment()); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString(' [WARNING] Install `pv` to see progress bar', $output); } public function testPullMultipleDatabases(): void { - $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE); + $this->setupPullDatabase(TRUE, TRUE, FALSE, TRUE, TRUE); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', @@ -141,18 +141,18 @@ public function testPullMultipleDatabases(): void { '--multiple-dbs' => TRUE, '--no-scripts' => TRUE, ], $inputs); - $this->prophet->checkPredictions(); + } public function testPullDatabasesOnDemand(): void { - $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, TRUE); + $this->setupPullDatabase(TRUE, TRUE, TRUE); $inputs = self::inputChooseEnvironment(); $this->executeCommand([ '--no-scripts' => TRUE, '--on-demand' => TRUE, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application', $output); @@ -164,13 +164,13 @@ public function testPullDatabasesOnDemand(): void { } public function testPullDatabasesNoExistingBackup(): void { - $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, 0, FALSE); + $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, FALSE, 0, FALSE); $inputs = self::inputChooseEnvironment(); $this->executeCommand([ '--no-scripts' => TRUE, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application', $output); @@ -183,14 +183,14 @@ public function testPullDatabasesNoExistingBackup(): void { } public function testPullDatabasesSiteArgument(): void { - $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE); + $this->setupPullDatabase(TRUE, TRUE, FALSE, FALSE); $inputs = self::inputChooseEnvironment(); $this->executeCommand([ '--no-scripts' => TRUE, 'site' => 'jxr5000596dev', ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application', $output); @@ -201,27 +201,45 @@ public function testPullDatabasesSiteArgument(): void { } public function testPullDatabaseWithMySqlDropError(): void { - $this->setupPullDatabase(TRUE, FALSE, TRUE); - $inputs = self::inputChooseEnvironment(); + $localMachineHelper = $this->mockLocalMachineHelper(); + $this->mockExecuteMySqlConnect($localMachineHelper, TRUE); + $environment = $this->mockGetEnvironment(); + $sshHelper = $this->mockSshHelper(); + $this->mockListSites($sshHelper); + $this->mockGetBackup($environment); + $this->mockExecuteMySqlListTables($localMachineHelper, 'drupal'); + $this->mockExecuteMySqlDropDb($localMachineHelper, FALSE); + $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to drop tables from database'); - $this->executeCommand(['--no-scripts' => TRUE], $inputs); + $this->executeCommand([ + '--no-scripts' => TRUE, + ], self::inputChooseEnvironment()); } public function testPullDatabaseWithMySqlImportError(): void { - $this->setupPullDatabase(TRUE, TRUE, FALSE); - $inputs = self::inputChooseEnvironment(); + $localMachineHelper = $this->mockLocalMachineHelper(); + $this->mockExecuteMySqlConnect($localMachineHelper, TRUE); + $environment = $this->mockGetEnvironment(); + $sshHelper = $this->mockSshHelper(); + $this->mockListSites($sshHelper); + $this->mockGetBackup($environment); + $this->mockExecuteMySqlListTables($localMachineHelper, 'drupal'); + $this->mockExecuteMySqlDropDb($localMachineHelper, TRUE); + $this->mockExecuteMySqlImport($localMachineHelper, FALSE, TRUE, 'my_db', 'my_dbdev', 'drupal'); $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to import local database'); - $this->executeCommand(['--no-scripts' => TRUE], $inputs); + $this->executeCommand([ + '--no-scripts' => TRUE, + ], self::inputChooseEnvironment()); } /** * @dataProvider providerTestPullDatabaseWithInvalidSslCertificate */ public function testPullDatabaseWithInvalidSslCertificate(int $errorCode): void { - $this->setupPullDatabase(TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, $errorCode); + $this->setupPullDatabase(TRUE, FALSE, FALSE, TRUE, FALSE, $errorCode); $inputs = self::inputChooseEnvironment(); $this->executeCommand(['--no-scripts' => TRUE], $inputs); @@ -230,7 +248,7 @@ public function testPullDatabaseWithInvalidSslCertificate(int $errorCode): void $this->assertStringContainsString('Trying alternative host other.example.com', $output); } - protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mysqlDropSuccessful, bool $mysqlImportSuccessful, bool $mockIdeFs = FALSE, bool $onDemand = FALSE, bool $mockGetAcsfSites = TRUE, bool $multiDb = FALSE, int $curlCode = 0, bool $existingBackups = TRUE): void { + protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mockIdeFs = FALSE, bool $onDemand = FALSE, bool $mockGetAcsfSites = TRUE, bool $multiDb = FALSE, int $curlCode = 0, bool $existingBackups = TRUE): void { $applicationsResponse = $this->mockApplicationsRequest(); $this->mockApplicationRequest(); $environmentsResponse = $this->mockAcsfEnvironmentsRequest($applicationsResponse); @@ -273,11 +291,11 @@ protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mysqlDr // Database. $this->mockExecuteMySqlListTables($localMachineHelper); - $this->mockExecuteMySqlDropDb($localMachineHelper, $mysqlDropSuccessful); - $this->mockExecuteMySqlImport($localMachineHelper, $mysqlImportSuccessful, TRUE); + $this->mockExecuteMySqlDropDb($localMachineHelper, TRUE); + $this->mockExecuteMySqlImport($localMachineHelper, TRUE, TRUE); if ($multiDb) { $this->mockExecuteMySqlListTables($localMachineHelper, 'drupal'); - $this->mockExecuteMySqlImport($localMachineHelper, $mysqlImportSuccessful, TRUE, 'profserv2', 'profserv2dev', 'drupal'); + $this->mockExecuteMySqlImport($localMachineHelper, TRUE, TRUE, 'profserv2', 'profserv2dev', 'drupal'); } } diff --git a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php index 64406773a..a949ea687 100644 --- a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php @@ -45,7 +45,7 @@ public function testRefreshAcsfFiles(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -82,7 +82,7 @@ public function testRefreshCloudFiles(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application', $output); diff --git a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php index dbd343b8c..25aa4780d 100644 --- a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php @@ -49,7 +49,7 @@ public function testRefreshScripts(): void { $this->executeCommand([ '--dir' => $this->projectDir, ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); } diff --git a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php index 9a2bcafed..731daf721 100644 --- a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php @@ -44,7 +44,7 @@ public function testPushArtifact(): void { 0, ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -89,7 +89,7 @@ public function testPushTagArtifact(): void { '--destination-git-tag' => $gitTag, '--source-git-tag' => '1.2.0', ], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -111,7 +111,7 @@ public function testPushArtifactWithAcquiaCliFile(): void { $this->executeCommand([ '--destination-git-branch' => 'master', ]); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Pushing changes to Acquia Git (https://github.com/example1/cli.git)', $output); @@ -132,7 +132,7 @@ public function testPushArtifactWithArgs(): void { '--destination-git-branch' => 'master', '--destination-git-urls' => $destinationGitUrls, ]); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Pushing changes to Acquia Git (https://github.com/example1/cli.git)', $output); @@ -156,7 +156,7 @@ public function testPushArtifactNoPush(): void { 0, ]; $this->executeCommand(['--no-push' => TRUE], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Initializing Git', $output); @@ -181,7 +181,7 @@ public function testPushArtifactNoCommit(): void { 0, ]; $this->executeCommand(['--no-commit' => TRUE], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Initializing Git', $output); @@ -203,7 +203,7 @@ public function testPushArtifactNoClone(): void { 0, ]; $this->executeCommand(['--no-clone' => TRUE], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringNotContainsString('Initializing Git', $output); diff --git a/tests/phpunit/src/Commands/Push/PushCodeCommandTest.php b/tests/phpunit/src/Commands/Push/PushCodeCommandTest.php index b6723cf18..cc65e14cb 100644 --- a/tests/phpunit/src/Commands/Push/PushCodeCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushCodeCommandTest.php @@ -19,7 +19,7 @@ protected function createCommand(): CommandBase { public function testPushCode(): void { $this->executeCommand(); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Use git to push code changes upstream.', $output); diff --git a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php index ce0a1872d..f3d3e5b0a 100644 --- a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php @@ -62,7 +62,7 @@ public function testPushDatabase(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); diff --git a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php index ee0debf83..f4767f6ea 100644 --- a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php @@ -44,7 +44,7 @@ public function testPushFilesAcsf(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -82,7 +82,7 @@ public function testPushFilesCloud(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); @@ -118,7 +118,7 @@ public function testPushFilesNoOverwrite(): void { ]; $this->executeCommand([], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Select a Cloud Platform application:', $output); diff --git a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php index 3532e4dd4..febd9a796 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php @@ -79,7 +79,7 @@ public function testRemoteAliasesDownloadCommand(array $inputs, array $args, str $this->executeCommand($args, $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertFileDoesNotExist($drushArchiveFilepath); diff --git a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php index cb8618d78..87c68502a 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php @@ -33,7 +33,7 @@ public function testRemoteAliasesListCommand(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('| Sample application 1 | devcloud2.dev | 24-a47ac10b-58cc-4372-a567-0e02b2c3d470 |', $output); diff --git a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php index 9c7a2c642..83ac85907 100644 --- a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php @@ -71,7 +71,7 @@ public function testRemoteDrushCommand(array $args): void { $this->executeCommand($args); // Assert. - $this->prophet->checkPredictions(); + $this->getDisplay(); } diff --git a/tests/phpunit/src/Commands/Remote/SshCommandTest.php b/tests/phpunit/src/Commands/Remote/SshCommandTest.php index 5f3e32843..9cf2db766 100644 --- a/tests/phpunit/src/Commands/Remote/SshCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/SshCommandTest.php @@ -49,7 +49,7 @@ public function testRemoteAliasesDownloadCommand(): void { $this->executeCommand($args); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); } diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php index bc7e9975d..23d69be25 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php @@ -65,6 +65,7 @@ public function providerTestCreate(): array { /** * @dataProvider providerTestCreate + * @group brokenProphecy */ public function testCreate(mixed $sshAddSuccess, mixed $args, mixed $inputs): void { $sshKeyFilepath = Path::join($this->sshDir, '/' . $this->filename); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php index c2430e129..b0fe12364 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php @@ -68,7 +68,7 @@ public function testCreateUpload(): void { $mockRequestArgs['label'], ]; $this->executeCommand(['--no-wait' => ''], $inputs); - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Enter the filename of the SSH key (option --filename) [id_rsa_acquia]:', $output); $this->assertStringContainsString('Enter the password for the SSH key (option --password) (input will be hidden):', $output); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php index 3f95818ac..aba8c0687 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php @@ -30,7 +30,7 @@ public function testDelete(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Choose an SSH key to delete from the Cloud Platform', $output); $this->assertStringContainsString($sshKeyListResponse[self::$INPUT_DEFAULT_CHOICE]->label, $output); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php index 95c4937cf..787fc4629 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php @@ -30,7 +30,7 @@ public function testInfo(): void { $this->executeCommand([], $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Choose an SSH key to view', $output); $this->assertStringContainsString('SSH key property SSH key value', $output); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php index 3dd5e8cb9..7ed1a1290 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php @@ -33,7 +33,7 @@ public function testList(): void { $this->executeCommand(); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString('Local filename', $output); $this->assertStringContainsString('Cloud Platform label', $output); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php index ad9ba4412..885bda9d9 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php @@ -97,7 +97,7 @@ public function testUpload(array $args, array $inputs, bool $perms): void { $this->executeCommand($args, $inputs); // Assert. - $this->prophet->checkPredictions(); + $output = $this->getDisplay(); $this->assertStringContainsString("Uploaded $fileName to the Cloud Platform with label " . $sshKeysRequestBody['label'], $output); $this->assertStringContainsString('Would you like to wait until your key is installed on all of your application\'s servers?', $output); diff --git a/tests/phpunit/src/Commands/TelemetryCommandTest.php b/tests/phpunit/src/Commands/TelemetryCommandTest.php index f1dac1739..3a7fe62f5 100644 --- a/tests/phpunit/src/Commands/TelemetryCommandTest.php +++ b/tests/phpunit/src/Commands/TelemetryCommandTest.php @@ -30,6 +30,9 @@ protected function createCommand(): CommandBase { return $this->injectCommand(TelemetryCommand::class); } + /** + * @group brokenProphecy + */ public function testTelemetryCommand(): void { $this->mockRequest('getAccount'); $this->executeCommand(); @@ -83,7 +86,7 @@ public function testAmplitudeDisabled(): void { $this->executeCommand(); $this->assertEquals(0, $this->getStatusCode()); - $this->prophet->checkPredictions(); + } public function testMigrateLegacyTelemetryPreference(): void { @@ -94,7 +97,7 @@ public function testMigrateLegacyTelemetryPreference(): void { $contents = json_encode($legacyAcliConfig); $this->fs->dumpFile($this->legacyAcliConfigFilepath, $contents); $this->executeCommand(); - $this->prophet->checkPredictions(); + $this->assertEquals(0, $this->getStatusCode()); $this->fs->remove($this->legacyAcliConfigFilepath); } diff --git a/tests/phpunit/src/Commands/WizardTestBase.php b/tests/phpunit/src/Commands/WizardTestBase.php index 35671396d..a4d2daefb 100644 --- a/tests/phpunit/src/Commands/WizardTestBase.php +++ b/tests/phpunit/src/Commands/WizardTestBase.php @@ -95,7 +95,7 @@ protected function runTestCreate(): void { ]); // Assertions. - $this->prophet->checkPredictions(); + } protected function runTestSshKeyAlreadyUploaded(): void {