From 4bfe4f46e40cfb970e38dddbf12f638fbdb0795e Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 11 Jul 2024 11:56:14 -0700 Subject: [PATCH 1/4] Fix array indentation --- .editorconfig | 5 +- phpcs.xml.dist | 5 +- src/AcsfApi/AcsfConnector.php | 10 +- src/CloudApi/ClientService.php | 2 +- src/CloudApi/ConnectorFactory.php | 10 +- src/Command/Acsf/AcsfListCommandBase.php | 4 +- src/Command/Api/ApiBaseCommand.php | 20 +- src/Command/Api/ApiCommandHelper.php | 38 +- src/Command/Api/ApiListCommandBase.php | 4 +- src/Command/App/AppVcsInfo.php | 6 +- .../App/From/Composer/ProjectBuilder.php | 22 +- src/Command/App/From/Configuration.php | 2 +- .../AbandonmentRecommendation.php | 34 +- .../Recommendation/DefinedRecommendation.php | 68 +- .../From/SourceSite/Drupal7SiteInspector.php | 10 +- src/Command/App/NewCommand.php | 46 +- src/Command/App/NewFromDrupal7Command.php | 38 +- src/Command/Auth/AuthAcsfLoginCommand.php | 14 +- src/Command/Auth/AuthLoginCommand.php | 10 +- .../CodeStudio/CodeStudioCiCdVariables.php | 168 ++--- .../CodeStudio/CodeStudioCommandTrait.php | 84 +-- .../CodeStudioPipelinesMigrateCommand.php | 112 +-- .../CodeStudio/CodeStudioWizardCommand.php | 78 +-- src/Command/CommandBase.php | 110 +-- src/Command/DocsCommand.php | 144 ++-- .../Email/ConfigurePlatformEmailCommand.php | 18 +- .../Email/EmailInfoForSubscriptionCommand.php | 52 +- src/Command/Env/EnvCopyCronCommand.php | 18 +- src/Command/Env/EnvCreateCommand.php | 4 +- src/Command/Env/EnvDeleteCommand.php | 2 +- src/Command/Env/EnvMirrorCommand.php | 12 +- src/Command/Ide/IdeCommandBase.php | 18 +- src/Command/Ide/IdeCreateCommand.php | 2 +- src/Command/Ide/IdeListCommand.php | 8 +- src/Command/Ide/IdeListMineCommand.php | 14 +- src/Command/Ide/IdeServiceRestartCommand.php | 20 +- src/Command/Ide/IdeServiceStartCommand.php | 20 +- src/Command/Ide/IdeServiceStopCommand.php | 20 +- src/Command/Ide/IdeShareCommand.php | 4 +- .../Wizard/IdeWizardCreateSshKeyCommand.php | 4 +- src/Command/Pull/PullCommandBase.php | 94 +-- src/Command/Push/PushArtifactCommand.php | 88 +-- src/Command/Push/PushDatabaseCommand.php | 10 +- src/Command/Remote/AliasesDownloadCommand.php | 4 +- src/Command/Remote/DrushCommand.php | 6 +- src/Command/Remote/SshCommand.php | 2 +- src/Command/Self/ListCommand.php | 14 +- src/Command/Self/MakeDocsCommand.php | 12 +- src/Command/Ssh/SshKeyCommandBase.php | 32 +- src/Command/Ssh/SshKeyInfoCommand.php | 10 +- src/Command/Ssh/SshKeyListCommand.php | 18 +- src/Command/WizardCommandBase.php | 4 +- src/Exception/AcquiaCliException.php | 4 +- src/Helpers/LocalMachineHelper.php | 6 +- src/Helpers/SshCommandTrait.php | 4 +- src/Helpers/SshHelper.php | 18 +- src/Helpers/TelemetryHelper.php | 64 +- src/Kernel.php | 20 +- src/Output/Spinner/Spinner.php | 120 ++-- tests/phpunit/src/AcsfApi/AcsfServiceTest.php | 32 +- .../ComposerScriptsListenerTest.php | 38 +- .../Application/ExceptionApplicationTest.php | 4 +- .../src/Application/HelpApplicationTest.php | 8 +- tests/phpunit/src/Application/KernelTest.php | 2 +- .../src/CloudApi/AccessTokenConnectorTest.php | 44 +- .../src/CloudApi/AcsfClientServiceTest.php | 16 +- .../src/CloudApi/ClientServiceTest.php | 32 +- tests/phpunit/src/CommandTestBase.php | 178 ++--- .../src/Commands/Acsf/AcsfApiCommandTest.php | 20 +- .../Acsf/AcsfAuthLoginCommandTest.php | 102 +-- .../Acsf/AcsfAuthLogoutCommandTest.php | 32 +- .../src/Commands/Acsf/AcsfCommandTestBase.php | 28 +- .../src/Commands/Api/ApiCommandTest.php | 76 +- .../src/Commands/App/AppVcsInfoTest.php | 14 +- .../From/AbandonmentRecommendationTest.php | 12 +- .../Commands/App/From/ConfigurationTest.php | 4 +- .../App/From/DefinedRecommendationTest.php | 242 +++---- .../Commands/App/From/ProjectBuilderTest.php | 46 +- .../Commands/App/From/RecommendationsTest.php | 68 +- .../src/Commands/App/LinkCommandTest.php | 4 +- .../src/Commands/App/LogTailCommandTest.php | 24 +- .../src/Commands/App/NewCommandTest.php | 58 +- .../App/NewFromDrupal7CommandTest.php | 46 +- .../src/Commands/App/TaskWaitCommandTest.php | 48 +- .../Archive/ArchiveExporterCommandTest.php | 4 +- .../Commands/Auth/AuthLoginCommandTest.php | 28 +- .../Commands/Auth/AuthLogoutCommandTest.php | 16 +- .../src/Commands/ClearCacheCommandTest.php | 2 +- .../CodeStudioPhpVersionCommandTest.php | 76 +- .../CodeStudioPipelinesMigrateCommandTest.php | 110 +-- .../CodeStudioWizardCommandTest.php | 658 +++++++++--------- .../phpunit/src/Commands/CommandBaseTest.php | 16 +- .../phpunit/src/Commands/DocsCommandTest.php | 144 ++-- .../ConfigurePlatformEmailCommandTest.php | 346 ++++----- .../EmailInfoForSubscriptionCommandTest.php | 14 +- .../Commands/Env/EnvCertCreateCommandTest.php | 66 +- .../Commands/Env/EnvCopyCronCommandTest.php | 22 +- .../src/Commands/Env/EnvCreateCommandTest.php | 24 +- .../src/Commands/Env/EnvDeleteCommandTest.php | 18 +- .../src/Commands/Env/EnvMirrorCommandTest.php | 26 +- .../src/Commands/Ide/IdeCreateCommandTest.php | 8 +- .../src/Commands/Ide/IdeDeleteCommandTest.php | 24 +- tests/phpunit/src/Commands/Ide/IdeHelper.php | 8 +- .../src/Commands/Ide/IdeInfoCommandTest.php | 8 +- .../Commands/Ide/IdeListCommandMineTest.php | 6 +- .../src/Commands/Ide/IdeListCommandTest.php | 12 +- .../src/Commands/Ide/IdeOpenCommandTest.php | 8 +- .../Commands/Ide/IdePhpVersionCommandTest.php | 26 +- .../Ide/IdeXdebugToggleCommandTest.php | 12 +- .../src/Commands/InferApplicationTest.php | 12 +- .../src/Commands/Pull/PullCodeCommandTest.php | 40 +- .../src/Commands/Pull/PullCommandTest.php | 14 +- .../src/Commands/Pull/PullCommandTestBase.php | 112 +-- .../Commands/Pull/PullDatabaseCommandTest.php | 56 +- .../Commands/Pull/PullFilesCommandTest.php | 20 +- .../Commands/Pull/PullScriptsCommandTest.php | 10 +- .../Commands/Push/PushArtifactCommandTest.php | 86 +-- .../Commands/Push/PushDatabaseCommandTest.php | 56 +- .../Commands/Push/PushFilesCommandTest.php | 56 +- .../Remote/AliasesDownloadCommandTest.php | 8 +- .../Remote/AliasesListCommandTest.php | 6 +- .../src/Commands/Remote/DrushCommandTest.php | 42 +- .../src/Commands/Remote/SshCommandTest.php | 16 +- .../Commands/Ssh/SshKeyCreateCommandTest.php | 66 +- .../Ssh/SshKeyCreateUploadCommandTest.php | 18 +- .../Commands/Ssh/SshKeyDeleteCommandTest.php | 4 +- .../Commands/Ssh/SshKeyInfoCommandTest.php | 2 +- .../Commands/Ssh/SshKeyUploadCommandTest.php | 82 +-- .../src/Commands/TelemetryCommandTest.php | 8 +- tests/phpunit/src/Commands/WizardTestBase.php | 28 +- tests/phpunit/src/Misc/EnvDbCredsTest.php | 8 +- .../src/Misc/ExceptionListenerTest.php | 120 ++-- .../src/Misc/LocalMachineHelperTest.php | 16 +- .../phpunit/src/Misc/TelemetryHelperTest.php | 16 +- tests/phpunit/src/TestBase.php | 62 +- 135 files changed, 2807 insertions(+), 2807 deletions(-) diff --git a/.editorconfig b/.editorconfig index 5044247d2..51d29a157 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,10 +4,7 @@ root = true [*] charset = utf-8 indent_style = space -indent_size = 2 +indent_size = 4 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true - -[composer.{json,lock}] -indent_size = 4 diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 389eea79e..11def6e88 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -26,7 +26,10 @@ - + + + + diff --git a/src/AcsfApi/AcsfConnector.php b/src/AcsfApi/AcsfConnector.php index 24dc8778e..69b1d3af2 100644 --- a/src/AcsfApi/AcsfConnector.php +++ b/src/AcsfApi/AcsfConnector.php @@ -20,11 +20,11 @@ public function __construct(array $config, string $baseUri = null, string $urlAc parent::__construct($config, $baseUri, $urlAccessToken); $this->client = new GuzzleClient([ - 'auth' => [ - $config['key'], - $config['secret'], - ], - 'base_uri' => $this->getBaseUri(), + 'auth' => [ + $config['key'], + $config['secret'], + ], + 'base_uri' => $this->getBaseUri(), ]); } diff --git a/src/CloudApi/ClientService.php b/src/CloudApi/ClientService.php index 95acecea6..5021deaca 100644 --- a/src/CloudApi/ClientService.php +++ b/src/CloudApi/ClientService.php @@ -53,7 +53,7 @@ protected function configureClient(Client $client): void { $userAgent = sprintf("acli/%s", $this->application->getVersion()); $customHeaders = [ - 'User-Agent' => [$userAgent], + 'User-Agent' => [$userAgent], ]; if ($uuid = getenv("REMOTEIDE_UUID")) { $customHeaders['X-Cloud-IDE-UUID'] = $uuid; diff --git a/src/CloudApi/ConnectorFactory.php b/src/CloudApi/ConnectorFactory.php index f8fd82488..5e1c99e73 100644 --- a/src/CloudApi/ConnectorFactory.php +++ b/src/CloudApi/ConnectorFactory.php @@ -33,9 +33,9 @@ public function createConnector(): Connector|AccessTokenConnector if (!$accessToken->hasExpired()) { // @todo Add debug log entry indicating that access token is being used. return new AccessTokenConnector([ - 'access_token' => $accessToken, - 'key' => null, - 'secret' => null, + 'access_token' => $accessToken, + 'key' => null, + 'secret' => null, ], $this->baseUri, $this->accountsUri); } } @@ -47,8 +47,8 @@ public function createConnector(): Connector|AccessTokenConnector private function createAccessToken(): AccessToken { return new AccessToken([ - 'access_token' => $this->config['accessToken'], - 'expires' => $this->config['accessTokenExpiry'], + 'access_token' => $this->config['accessToken'], + 'expires' => $this->config['accessTokenExpiry'], ]); } } diff --git a/src/Command/Acsf/AcsfListCommandBase.php b/src/Command/Acsf/AcsfListCommandBase.php index 3778dce33..f26bca61e 100644 --- a/src/Command/Acsf/AcsfListCommandBase.php +++ b/src/Command/Acsf/AcsfListCommandBase.php @@ -37,8 +37,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command = $this->getApplication()->find('list'); $arguments = [ - 'command' => 'list', - 'namespace' => 'acsf', + 'command' => 'list', + 'namespace' => 'acsf', ]; $listInput = new ArrayInput($arguments); diff --git a/src/Command/Api/ApiBaseCommand.php b/src/Command/Api/ApiBaseCommand.php index 6149daf93..f6c05e099 100644 --- a/src/Command/Api/ApiBaseCommand.php +++ b/src/Command/Api/ApiBaseCommand.php @@ -62,8 +62,8 @@ protected function interact(InputInterface $input, OutputInterface $output): voi foreach ($this->getDefinition()->getArguments() as $argument) { if ($argument->isRequired() && !$input->getArgument($argument->getName())) { $this->io->note([ - "{$argument->getName()} is a required argument.", - $argument->getDescription(), + "{$argument->getName()} is a required argument.", + $argument->getDescription(), ]); // Choice question. if ( @@ -103,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // API calls returning octet streams (e.g., db backups). It's safe to use // here because the API command should always return JSON. $acquiaCloudClient->addOption('headers', [ - 'Accept' => 'application/hal+json, version=2', + 'Accept' => 'application/hal+json, version=2', ]); try { @@ -265,7 +265,7 @@ private function createCallableValidator(InputArgument $argument, array $params) if (array_key_exists($argument->getName(), $params)) { $paramSpec = $params[$argument->getName()]; $constraints = [ - new NotBlank(), + new NotBlank(), ]; if ($type = $this->getParamType($paramSpec)) { if (in_array($type, ['int', 'integer'])) { @@ -316,8 +316,8 @@ protected function createRegexConstraint(array $schema, array $constraints): arr } } elseif (array_key_exists('pattern', $schema)) { $constraints[] = new Regex([ - 'message' => 'It must match the pattern ' . $schema['pattern'], - 'pattern' => '/' . $schema['pattern'] . '/', + 'message' => 'It must match the pattern ' . $schema['pattern'], + 'pattern' => '/' . $schema['pattern'] . '/', ]); } return $constraints; @@ -372,10 +372,10 @@ private function addPostParamToClient(string $paramName, ?array $paramSpec, mixe } if ($paramSpec && array_key_exists('format', $paramSpec) && $paramSpec["format"] === 'binary') { $acquiaCloudClient->addOption('multipart', [ - [ - 'contents' => Utils::tryFopen($paramValue, 'r'), - 'name' => $paramName, - ], + [ + 'contents' => Utils::tryFopen($paramValue, 'r'), + 'name' => $paramName, + ], ]); } else { $acquiaCloudClient->addOption('json', [$paramName => $paramValue]); diff --git a/src/Command/Api/ApiCommandHelper.php b/src/Command/Api/ApiCommandHelper.php index 867a3d84a..2be9124e7 100644 --- a/src/Command/Api/ApiCommandHelper.php +++ b/src/Command/Api/ApiCommandHelper.php @@ -84,8 +84,8 @@ private function addApiCommandParameters(array $schema, array $acquiaCloudSpec, // Parameters to be used in the request body. if (array_key_exists('requestBody', $schema)) { [ - $bodyInputDefinition, - $requestBodyParamUsageSuffix, + $bodyInputDefinition, + $requestBodyParamUsageSuffix, ] = $this->addApiCommandParametersForRequestBody($schema, $acquiaCloudSpec); $requestBodySchema = $this->getRequestBodyFromParameterSchema($schema, $acquiaCloudSpec); /** @var \Symfony\Component\Console\Input\InputOption|InputArgument $parameterDefinition */ @@ -310,8 +310,8 @@ private function getCloudApiSpec(string $specFilePath): array $spec = json_decode(file_get_contents($specFilePath), true); $cache->warmUp([ - $cacheKey => $spec, - $cacheKey . '.checksum' => $checksum, + $cacheKey => $spec, + $cacheKey . '.checksum' => $checksum, ]); return $spec; @@ -367,17 +367,17 @@ protected function getSkippedApiCommands(): array return [ // Skip accounts:drush-aliases since we have remote:aliases:download instead and it actually returns // application/gzip content. - 'accounts:drush-aliases', + 'accounts:drush-aliases', // Skip any command that has a duplicative corresponding ACLI command. - 'ide:create', - 'log:tail', - 'ssh-key:create', - 'ssh-key:create-upload', - 'ssh-key:delete', - 'ssh-key:list', - 'ssh-key:upload', + 'ide:create', + 'log:tail', + 'ssh-key:create', + 'ssh-key:create-upload', + 'ssh-key:delete', + 'ssh-key:list', + 'ssh-key:upload', // Skip buggy or unsupported endpoints. - 'environments:stack-metrics-data-metric', + 'environments:stack-metrics-data-metric', ]; } @@ -440,9 +440,9 @@ protected static function getParameterRenameMap(): array // Format should be ['original => new']. return [ // @see api:environments:cron-create - 'command' => 'cron_command', + 'command' => 'cron_command', // @see api:environments:update. - 'version' => 'lang_version', + 'version' => 'lang_version', ]; } @@ -498,10 +498,10 @@ private function getRequestBodyContent(array $requestBody): array { $content = $requestBody['content']; $knownContentTypes = [ - 'application/hal+json', - 'application/json', - 'application/x-www-form-urlencoded', - 'multipart/form-data', + 'application/hal+json', + 'application/json', + 'application/x-www-form-urlencoded', + 'multipart/form-data', ]; foreach ($knownContentTypes as $contentType) { if (array_key_exists($contentType, $content)) { diff --git a/src/Command/Api/ApiListCommandBase.php b/src/Command/Api/ApiListCommandBase.php index 9234d1496..426895845 100644 --- a/src/Command/Api/ApiListCommandBase.php +++ b/src/Command/Api/ApiListCommandBase.php @@ -36,8 +36,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command = $this->getApplication()->find('list'); $arguments = [ - 'command' => 'list', - 'namespace' => 'api', + 'command' => 'list', + 'namespace' => 'api', ]; $listInput = new ArrayInput($arguments); diff --git a/src/Command/App/AppVcsInfo.php b/src/Command/App/AppVcsInfo.php index 85250d224..0d7c868fb 100644 --- a/src/Command/App/AppVcsInfo.php +++ b/src/Command/App/AppVcsInfo.php @@ -82,11 +82,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table->setHeaderTitle('Status of Branches and Tags of the Application'); foreach ($allVcs as $vscPath => $env) { $table->addRow([ - $vscPath, + $vscPath, // If VCS and env name is not same, it means it is deployed. - $vscPath !== $env ? 'Yes' : 'No', + $vscPath !== $env ? 'Yes' : 'No', // If VCS and env name is same, it means it is deployed. - $vscPath !== $env ? $env : 'None', + $vscPath !== $env ? $env : 'None', ]); } diff --git a/src/Command/App/From/Composer/ProjectBuilder.php b/src/Command/App/From/Composer/ProjectBuilder.php index 71a17b6a9..2aface12f 100644 --- a/src/Command/App/From/Composer/ProjectBuilder.php +++ b/src/Command/App/From/Composer/ProjectBuilder.php @@ -127,9 +127,9 @@ public function buildProject(): array $source_modules = array_values(array_map(function (ExtensionInterface $module) { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return [ - 'name' => $module->getName(), - 'humanName' => $module->getHumanName(), - 'version' => $module->getVersion(), + 'name' => $module->getName(), + 'humanName' => $module->getHumanName(), + 'version' => $module->getVersion(), ]; // phpcs:enable }, $this->siteInspector->getExtensions(SiteInspectorInterface::FLAG_EXTENSION_MODULE | SiteInspectorInterface::FLAG_EXTENSION_ENABLED))); @@ -141,14 +141,14 @@ public function buildProject(): array // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return [ - 'installModules' => $modules_to_install, - 'filePaths' => [ - 'public' => $this->siteInspector->getPublicFilePath(), - 'private' => $this->siteInspector->getPrivateFilePath(), - ], - 'sourceModules' => $source_modules, - 'recommendations' => $recommendations, - 'rootPackageDefinition' => $composer_json, + 'installModules' => $modules_to_install, + 'filePaths' => [ + 'public' => $this->siteInspector->getPublicFilePath(), + 'private' => $this->siteInspector->getPrivateFilePath(), + ], + 'sourceModules' => $source_modules, + 'recommendations' => $recommendations, + 'rootPackageDefinition' => $composer_json, ]; // phpcs:enable } diff --git a/src/Command/App/From/Configuration.php b/src/Command/App/From/Configuration.php index bacf660d0..30116a4e8 100644 --- a/src/Command/App/From/Configuration.php +++ b/src/Command/App/From/Configuration.php @@ -30,7 +30,7 @@ final class Configuration protected function __construct(array $config) { $this->array = static::schema([ - 'rootPackageDefinition' => 'is_array', + 'rootPackageDefinition' => 'is_array', ])($config); } diff --git a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php index 2b90af450..c90a1709a 100644 --- a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php +++ b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php @@ -66,12 +66,12 @@ public static function createFromDefinition(mixed $definition): RecommendationIn { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $validator = static::schema([ - 'package' => 'is_null', - 'note' => 'is_string', - 'replaces' => static::schema([ - 'name' => 'is_string', - ]), - 'vetted' => 'is_bool', + 'package' => 'is_null', + 'note' => 'is_string', + 'replaces' => static::schema([ + 'name' => 'is_string', + ]), + 'vetted' => 'is_bool', ]); // phpcs:enable try { @@ -145,20 +145,20 @@ public function normalize(): array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $normalized = [ - 'type' => 'abandonmentRecommendation', - 'id' => "abandon:{$this->definition['replaces']['name']}", - 'attributes' => [ - 'note' => $this->definition['note'], - ], + 'type' => 'abandonmentRecommendation', + 'id' => "abandon:{$this->definition['replaces']['name']}", + 'attributes' => [ + 'note' => $this->definition['note'], + ], ]; $recommended_for = [ - 'data' => array_map(function (ExtensionInterface $extension) { - return [ - 'type' => $extension->isModule() ? 'module' : 'theme', - 'id' => $extension->getName(), - ]; - }, $this->appliedTo), + 'data' => array_map(function (ExtensionInterface $extension) { + return [ + 'type' => $extension->isModule() ? 'module' : 'theme', + 'id' => $extension->getName(), + ]; + }, $this->appliedTo), ]; // phpcs:enable if (!empty($recommended_for['data'])) { diff --git a/src/Command/App/From/Recommendation/DefinedRecommendation.php b/src/Command/App/From/Recommendation/DefinedRecommendation.php index fc06cfa4d..1524be745 100644 --- a/src/Command/App/From/Recommendation/DefinedRecommendation.php +++ b/src/Command/App/From/Recommendation/DefinedRecommendation.php @@ -119,11 +119,11 @@ public static function createFromDefinition(mixed $definition): RecommendationIn { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $defaults = [ - 'universal' => false, - 'patches' => [], - 'install' => [], - 'vetted' => false, - 'note' => static::NOTE_PLACEHOLDER_STRING, + 'universal' => false, + 'patches' => [], + 'install' => [], + 'vetted' => false, + 'note' => static::NOTE_PLACEHOLDER_STRING, ]; $validate_if_universal_is_false = Closure::fromCallable(function ($context) { return $context['universal'] === false; @@ -134,16 +134,16 @@ public static function createFromDefinition(mixed $definition): RecommendationIn } $validator = static::schema([ - 'universal' => 'is_bool', - 'install' => static::listOf('is_string'), - 'package' => 'is_string', - 'constraint' => 'is_string', - 'note' => 'is_string', - 'replaces' => static::conditionalSchema([ - 'name' => 'is_string', - ], $validate_if_universal_is_false), - 'patches' => static::dictionaryOf('is_string'), - 'vetted' => 'is_bool', + 'universal' => 'is_bool', + 'install' => static::listOf('is_string'), + 'package' => 'is_string', + 'constraint' => 'is_string', + 'note' => 'is_string', + 'replaces' => static::conditionalSchema([ + 'name' => 'is_string', + ], $validate_if_universal_is_false), + 'patches' => static::dictionaryOf('is_string'), + 'vetted' => 'is_bool', ], $defaults); // phpcs:enable try { @@ -226,16 +226,16 @@ public function normalize(): array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $normalized = [ - 'type' => 'packageRecommendation', - 'id' => "{$this->packageName}:{$this->versionConstraint}", - 'attributes' => [ - 'requirePackage' => [ - 'name' => $this->packageName, - 'versionConstraint' => $this->versionConstraint, - ], - 'installModules' => $this->install, - 'vetted' => $this->vetted, - ], + 'type' => 'packageRecommendation', + 'id' => "{$this->packageName}:{$this->versionConstraint}", + 'attributes' => [ + 'requirePackage' => [ + 'name' => $this->packageName, + 'versionConstraint' => $this->versionConstraint, + ], + 'installModules' => $this->install, + 'vetted' => $this->vetted, + ], ]; if (!empty($this->note) && $this->note !== static::NOTE_PLACEHOLDER_STRING) { @@ -243,12 +243,12 @@ public function normalize(): array } $recommended_for = [ - 'data' => array_map(function (ExtensionInterface $extension) { - return [ - 'type' => $extension->isModule() ? 'module' : 'theme', - 'id' => $extension->getName(), - ]; - }, $this->appliedTo), + 'data' => array_map(function (ExtensionInterface $extension) { + return [ + 'type' => $extension->isModule() ? 'module' : 'theme', + 'id' => $extension->getName(), + ]; + }, $this->appliedTo), ]; // phpcs:enable if (!empty($recommended_for['data'])) { @@ -257,9 +257,9 @@ public function normalize(): array $links = array_reduce(array_keys($this->patches), function (array $links, string $patch_description) { $links['patch-file--' . md5($patch_description)] = [ - 'href' => $this->patches[$patch_description], - 'rel' => 'https://github.com/acquia/acquia_migrate#link-rel-patch-file', - 'title' => $patch_description, + 'href' => $this->patches[$patch_description], + 'rel' => 'https://github.com/acquia/acquia_migrate#link-rel-patch-file', + 'title' => $patch_description, ]; return $links; }, []); diff --git a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php index 78c51b85e..1a1e72c80 100644 --- a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php +++ b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php @@ -53,11 +53,11 @@ protected function readExtensions(): array $modules = array_values(array_map(function (string $name) use ($enabled) { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return (object) [ - 'name' => $name, - 'status' => true, - 'type' => 'module', - 'humanName' => $enabled[$name]->info['name'], - 'version' => $enabled[$name]->info['version'], + 'name' => $name, + 'status' => true, + 'type' => 'module', + 'humanName' => $enabled[$name]->info['name'], + 'version' => $enabled[$name]->info['version'], ]; // phpcs:enable }, array_keys($enabled))); diff --git a/src/Command/App/NewCommand.php b/src/Command/App/NewCommand.php index df2efb75b..9f53f723a 100644 --- a/src/Command/App/NewCommand.php +++ b/src/Command/App/NewCommand.php @@ -28,8 +28,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->output->writeln('Acquia recommends most customers use acquia/drupal-recommended-project to setup a Drupal project, which includes useful utilities such as Acquia Connector.'); $this->output->writeln('acquia/next-acms is a starter template for building a headless site powered by Acquia CMS and Next.js.'); $distros = [ - 'acquia_drupal_recommended' => 'acquia/drupal-recommended-project', - 'acquia_next_acms' => 'acquia/next-acms', + 'acquia_drupal_recommended' => 'acquia/drupal-recommended-project', + 'acquia_next_acms' => 'acquia/next-acms', ]; $project = $this->io->choice('Choose a starting project', array_values($distros), $distros['acquia_drupal_recommended']); $project = array_search($project, $distros, true); @@ -66,11 +66,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function createNextJsProject(string $dir): void { $process = $this->localMachineHelper->execute([ - 'npx', - 'create-next-app', - '-e', - 'https://github.com/acquia/next-acms/tree/main/starters/basic-starter', - $dir, + 'npx', + 'create-next-app', + '-e', + 'https://github.com/acquia/next-acms/tree/main/starters/basic-starter', + $dir, ]); if (!$process->isSuccessful()) { throw new AcquiaCliException("Unable to create new next-acms project."); @@ -80,11 +80,11 @@ private function createNextJsProject(string $dir): void private function createDrupalProject(string $project, string $dir): void { $process = $this->localMachineHelper->execute([ - 'composer', - 'create-project', - $project, - $dir, - '--no-interaction', + 'composer', + 'create-project', + $project, + $dir, + '--no-interaction', ]); if (!$process->isSuccessful()) { throw new AcquiaCliException("Unable to create new project."); @@ -99,23 +99,23 @@ private function initializeGitRepository(string $dir): void } $this->localMachineHelper->checkRequiredBinariesExist(['git']); $this->localMachineHelper->execute([ - 'git', - 'init', - '--initial-branch=main', + 'git', + 'init', + '--initial-branch=main', ], null, $dir); $this->localMachineHelper->execute([ - 'git', - 'add', - '-A', + 'git', + 'add', + '-A', ], null, $dir); $this->localMachineHelper->execute([ - 'git', - 'commit', - '--message', - 'Initial commit.', - '--quiet', + 'git', + 'commit', + '--message', + 'Initial commit.', + '--quiet', ], null, $dir); // @todo Check that this was successful! } diff --git a/src/Command/App/NewFromDrupal7Command.php b/src/Command/App/NewFromDrupal7Command.php index cf1dba8e3..41669d226 100644 --- a/src/Command/App/NewFromDrupal7Command.php +++ b/src/Command/App/NewFromDrupal7Command.php @@ -24,9 +24,9 @@ #[AsCommand(name: 'app:new:from:drupal7', description: 'Generate a new Drupal 9+ project from a Drupal 7 application using the default Acquia Migrate Accelerate recommendations.', aliases: [ // Currently only "from Drupal 7", more to potentially follow. - 'from:d7', + 'from:d7', // A nod to its roots. - 'ama', + 'ama', ])] final class NewFromDrupal7Command extends CommandBase { @@ -200,11 +200,11 @@ function (mixed $path): string { $output->writeln('⏳ Installing. This may take a few minutes.'); $this->localMachineHelper->checkRequiredBinariesExist(['composer']); $process = $this->localMachineHelper->execute([ - 'composer', - 'install', - '--working-dir', - $dir, - '--no-interaction', + 'composer', + 'install', + '--working-dir', + $dir, + '--no-interaction', ]); if (!$process->isSuccessful()) { throw new AcquiaCliException("Unable to create new project."); @@ -224,24 +224,24 @@ private function initializeGitRepository(string $dir): void } $this->localMachineHelper->checkRequiredBinariesExist(['git']); $this->localMachineHelper->execute([ - 'git', - 'init', - '--initial-branch=main', - '--quiet', + 'git', + 'init', + '--initial-branch=main', + '--quiet', ], null, $dir); $this->localMachineHelper->execute([ - 'git', - 'add', - '-A', + 'git', + 'add', + '-A', ], null, $dir); $this->localMachineHelper->execute([ - 'git', - 'commit', - '--message', - "Generated by Acquia CLI's app:new:from:drupal7.", - '--quiet', + 'git', + 'commit', + '--message', + "Generated by Acquia CLI's app:new:from:drupal7.", + '--quiet', ], null, $dir); // @todo Check that this was successful! } diff --git a/src/Command/Auth/AuthAcsfLoginCommand.php b/src/Command/Auth/AuthAcsfLoginCommand.php index 8e424efe2..bedc80732 100644 --- a/src/Command/Auth/AuthAcsfLoginCommand.php +++ b/src/Command/Auth/AuthAcsfLoginCommand.php @@ -33,14 +33,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $factoryChoices[$url]['url'] = $url; } $factoryChoices['add_new'] = [ - 'url' => 'Enter a new factory URL', + 'url' => 'Enter a new factory URL', ]; $factory = $this->promptChooseFromObjectsOrArrays($factoryChoices, 'url', 'url', 'Choose a Factory to login to'); if ($factory['url'] === 'Enter a new factory URL') { $factoryUrl = $this->io->ask('Enter the full URL of the factory'); $factory = [ - 'url' => $factoryUrl, - 'users' => [], + 'url' => $factoryUrl, + 'users' => [], ]; } else { $factoryUrl = $factory['url']; @@ -48,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $users = $factory['users']; $users['add_new'] = [ - 'username' => 'Enter a new user', + 'username' => 'Enter a new user', ]; $selectedUser = $this->promptChooseFromObjectsOrArrays($users, 'username', 'username', 'Choose which user to login as'); if ($selectedUser['username'] !== 'Enter a new user') { @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $factories[$factoryUrl]['active_user'] = $selectedUser['username']; $this->datastoreCloud->set('acsf_factories', $factories); $output->writeln([ - "Acquia CLI is now logged in to {$factory['url']} as {$selectedUser['username']}", + "Acquia CLI is now logged in to {$factory['url']} as {$selectedUser['username']}", ]); return Command::SUCCESS; } @@ -77,8 +77,8 @@ private function writeAcsfCredentialsToDisk(?string $factoryUrl, string $usernam { $keys = $this->datastoreCloud->get('acsf_factories'); $keys[$factoryUrl]['users'][$username] = [ - 'key' => $key, - 'username' => $username, + 'key' => $key, + 'username' => $username, ]; $keys[$factoryUrl]['url'] = $factoryUrl; $keys[$factoryUrl]['active_user'] = $username; diff --git a/src/Command/Auth/AuthLoginCommand.php b/src/Command/Auth/AuthLoginCommand.php index ba8274741..4645c934d 100644 --- a/src/Command/Auth/AuthLoginCommand.php +++ b/src/Command/Auth/AuthLoginCommand.php @@ -40,8 +40,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $keys[$uuid]['uuid'] = $uuid; } $keys['create_new'] = [ - 'label' => 'Enter a new API key', - 'uuid' => 'create_new', + 'label' => 'Enter a new API key', + 'uuid' => 'create_new', ]; $selectedKey = $this->promptChooseFromObjectsOrArrays($keys, 'uuid', 'label', 'Activate a Cloud Platform API key'); if ($selectedKey['uuid'] !== 'create_new') { @@ -68,9 +68,9 @@ private function writeApiCredentialsToDisk(string $apiKey, string $apiSecret): v $accountInfo = $account->get(); $keys = $this->datastoreCloud->get('keys'); $keys[$apiKey] = [ - 'label' => $accountInfo->mail, - 'secret' => $apiSecret, - 'uuid' => $apiKey, + 'label' => $accountInfo->mail, + 'secret' => $apiSecret, + 'uuid' => $apiKey, ]; $this->datastoreCloud->set('keys', $keys); $this->datastoreCloud->set('acli_key', $apiKey); diff --git a/src/Command/CodeStudio/CodeStudioCiCdVariables.php b/src/Command/CodeStudio/CodeStudioCiCdVariables.php index d6f01d174..c57734a56 100644 --- a/src/Command/CodeStudio/CodeStudioCiCdVariables.php +++ b/src/Command/CodeStudio/CodeStudioCiCdVariables.php @@ -21,48 +21,48 @@ public static function getList(): array public static function getDefaultsForNode(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $nodeVersion = null): array { return [ - [ - 'key' => 'ACQUIA_APPLICATION_UUID', - 'masked' => true, - 'protected' => false, - 'value' => $cloudApplicationUuid, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', - 'masked' => true, - 'protected' => false, - 'value' => $cloudKey, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => $cloudSecret, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_NAME', - 'masked' => true, - 'protected' => false, - 'value' => $projectAccessTokenName, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => $projectAccessToken, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'NODE_VERSION', - 'masked' => false, - 'protected' => false, - 'value' => $nodeVersion, - 'variable_type' => 'env_var', - ], + [ + 'key' => 'ACQUIA_APPLICATION_UUID', + 'masked' => true, + 'protected' => false, + 'value' => $cloudApplicationUuid, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', + 'masked' => true, + 'protected' => false, + 'value' => $cloudKey, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => $cloudSecret, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_NAME', + 'masked' => true, + 'protected' => false, + 'value' => $projectAccessTokenName, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => $projectAccessToken, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'NODE_VERSION', + 'masked' => false, + 'protected' => false, + 'value' => $nodeVersion, + 'variable_type' => 'env_var', + ], ]; } @@ -72,48 +72,48 @@ public static function getDefaultsForNode(?string $cloudApplicationUuid = null, public static function getDefaultsForPhp(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $phpVersion = null): array { return [ - [ - 'key' => 'ACQUIA_APPLICATION_UUID', - 'masked' => true, - 'protected' => false, - 'value' => $cloudApplicationUuid, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', - 'masked' => true, - 'protected' => false, - 'value' => $cloudKey, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => $cloudSecret, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_NAME', - 'masked' => true, - 'protected' => false, - 'value' => $projectAccessTokenName, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => $projectAccessToken, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'PHP_VERSION', - 'masked' => false, - 'protected' => false, - 'value' => $phpVersion, - 'variable_type' => 'env_var', - ], + [ + 'key' => 'ACQUIA_APPLICATION_UUID', + 'masked' => true, + 'protected' => false, + 'value' => $cloudApplicationUuid, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', + 'masked' => true, + 'protected' => false, + 'value' => $cloudKey, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => $cloudSecret, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_NAME', + 'masked' => true, + 'protected' => false, + 'value' => $projectAccessTokenName, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => $projectAccessToken, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'PHP_VERSION', + 'masked' => false, + 'protected' => false, + 'value' => $phpVersion, + 'variable_type' => 'env_var', + ], ]; } } diff --git a/src/Command/CodeStudio/CodeStudioCommandTrait.php b/src/Command/CodeStudio/CodeStudioCommandTrait.php index fb7dfe7d9..44a81691d 100644 --- a/src/Command/CodeStudio/CodeStudioCommandTrait.php +++ b/src/Command/CodeStudio/CodeStudioCommandTrait.php @@ -41,24 +41,24 @@ private function getGitLabToken(string $gitlabHost): string throw new AcquiaCliException("Install glab to continue: https://gitlab.com/gitlab-org/cli#installation"); } $process = $this->localMachineHelper->execute([ - 'glab', - 'config', - 'get', - 'token', - '--host=' . $gitlabHost, + 'glab', + 'config', + 'get', + 'token', + '--host=' . $gitlabHost, ], null, null, false); if ($process->isSuccessful() && trim($process->getOutput())) { return trim($process->getOutput()); } $this->io->writeln([ - "", - "You must first authenticate with Code Studio by creating a personal access token:", - "* Visit https://$gitlabHost/-/profile/personal_access_tokens", - "* Create a token and grant it both api and write repository scopes", - "* Copy the token to your clipboard", - "* Run glab auth login --hostname=$gitlabHost and paste the token when prompted", - "* Try this command again.", + "", + "You must first authenticate with Code Studio by creating a personal access token:", + "* Visit https://$gitlabHost/-/profile/personal_access_tokens", + "* Create a token and grant it both api and write repository scopes", + "* Copy the token to your clipboard", + "* Run glab auth login --hostname=$gitlabHost and paste the token when prompted", + "* Try this command again.", ]); throw new AcquiaCliException("Could not determine GitLab token"); @@ -80,10 +80,10 @@ private function getGitLabHost(): string throw new AcquiaCliException("Install glab to continue: https://gitlab.com/gitlab-org/cli#installation"); } $process = $this->localMachineHelper->execute([ - 'glab', - 'config', - 'get', - 'host', + 'glab', + 'config', + 'get', + 'host', ], null, null, false); if (!$process->isSuccessful()) { throw new AcquiaCliException("Could not determine GitLab host: {error_message}", ['error_message' => $process->getErrorOutput()]); @@ -120,17 +120,17 @@ private function writeApiTokenMessage(InputInterface $input): void if (!$input->getOption('key') || !$input->getOption('secret')) { $tokenUrl = 'https://cloud.acquia.com/a/profile/tokens'; $this->io->writeln([ - "", - "This will configure AutoDevOps for a Code Studio project using credentials", - "(an API Token and SSH Key) belonging to your current Acquia Cloud Platform user account.", - "Before continuing, make sure that you're logged into the right Acquia Cloud Platform user account.", - "", - "Typically this command should only be run once per application", - "but if your Cloud Platform account is deleted in the future, the Code Studio project will", - "need to be re-configured using a different user account.", - "", - "To begin, visit this URL and create a new API Token for Code Studio to use:", - "$tokenUrl", + "", + "This will configure AutoDevOps for a Code Studio project using credentials", + "(an API Token and SSH Key) belonging to your current Acquia Cloud Platform user account.", + "Before continuing, make sure that you're logged into the right Acquia Cloud Platform user account.", + "", + "Typically this command should only be run once per application", + "but if your Cloud Platform account is deleted in the future, the Code Studio project will", + "need to be re-configured using a different user account.", + "", + "To begin, visit this URL and create a new API Token for Code Studio to use:", + "$tokenUrl", ]); } } @@ -152,11 +152,11 @@ private function authenticateWithGitLab(): void $this->gitLabAccount = $this->gitLabClient->users()->me(); } catch (RuntimeException $exception) { $this->io->error([ - "Unable to authenticate with Code Studio", - "Did you set a valid token with the api and write_repository scopes?", - "Try running `glab auth login` to re-authenticate.", - "Alternatively, pass the --gitlab-token option.", - "Then try again.", + "Unable to authenticate with Code Studio", + "Did you set a valid token with the api and write_repository scopes?", + "Try running `glab auth login` to re-authenticate.", + "Alternatively, pass the --gitlab-token option.", + "Then try again.", ]); throw new AcquiaCliException("Unable to authenticate with Code Studio"); } @@ -188,9 +188,9 @@ private function determineGitLabProject(ApplicationResponse $cloudApplication): } // Prompt to create project. $this->io->writeln([ - "", - "Could not find any existing Code Studio project for Acquia Cloud Platform application {$cloudApplication->name}.", - "Searched for UUID {$cloudApplication->uuid} in project descriptions.", + "", + "Could not find any existing Code Studio project for Acquia Cloud Platform application {$cloudApplication->name}.", + "Searched for UUID {$cloudApplication->uuid} in project descriptions.", ]); $createProject = $this->io->confirm('Would you like to create a new Code Studio project? If you select "no" you may choose from a full list of existing projects.'); if ($createProject) { @@ -211,8 +211,8 @@ private function determineGitLabProject(ApplicationResponse $cloudApplication): private function createGitLabProject(ApplicationResponse $cloudApplication): array { $userGroups = $this->gitLabClient->groups()->all([ - 'all_available' => true, - 'min_access_level' => 40, + 'all_available' => true, + 'min_access_level' => 40, ]); $parameters = $this->getGitLabProjectDefaults(); if ($userGroups) { @@ -246,11 +246,11 @@ private function setGitLabProjectDescription(mixed $cloudApplicationUuid): void private function getGitLabProjectDefaults(): array { return [ - 'container_registry_access_level' => 'disabled', - 'default_branch' => 'main', - 'description' => $this->gitLabProjectDescription, - 'initialize_with_readme' => true, - 'topics' => 'Acquia Cloud Application', + 'container_registry_access_level' => 'disabled', + 'default_branch' => 'main', + 'description' => $this->gitLabProjectDescription, + 'initialize_with_readme' => true, + 'topics' => 'Acquia Cloud Application', ]; } diff --git a/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php b/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php index 46994b7c1..1dcf3aed5 100644 --- a/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php +++ b/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php @@ -66,11 +66,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->removeEmptyScript($gitlabCiFileContents); $this->createGitLabCiFile($gitlabCiFileContents, $acquiaPipelinesFileName); $this->io->success([ - "", - "Migration completed successfully.", - "Created .gitlab-ci.yml and removed acquia-pipeline.yml file.", - "In order to run Pipeline, push .gitlab-ci.yaml to Main branch of Code Studio project.", - "Check your pipeline is running in Code Studio for your project.", + "", + "Migration completed successfully.", + "Created .gitlab-ci.yml and removed acquia-pipeline.yml file.", + "In order to run Pipeline, push .gitlab-ci.yaml to Main branch of Code Studio project.", + "Check your pipeline is running in Code Studio for your project.", ]); return Command::SUCCESS; @@ -111,8 +111,8 @@ private function getAcquiaPipelinesFileContents(array $project): array if (file_exists($pipelinesFilepath)) { $fileContents = file_get_contents($pipelinesFilepath); return [ - 'filename' => $pipelinesFilename, - 'file_contents' => Yaml::parse($fileContents, Yaml::PARSE_OBJECT), + 'filename' => $pipelinesFilename, + 'file_contents' => Yaml::parse($fileContents, Yaml::PARSE_OBJECT), ]; } } @@ -129,7 +129,7 @@ private function getAcquiaPipelinesFileContents(array $project): array private function getGitLabCiFileTemplate(): array { return [ - 'include' => ['project' => 'acquia/standard-template', 'file' => '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'], + 'include' => ['project' => 'acquia/standard-template', 'file' => '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'], ]; } @@ -144,11 +144,11 @@ private function migrateVariablesSection(mixed $acquiaPipelinesFileContents, mix $variablesParse = Yaml::parse($removeGlobal); $gitlabCiFileContents = array_merge($gitlabCiFileContents, $variablesParse); $this->io->success([ - "Migrated `variables` section of acquia-pipelines.yml to .gitlab-ci.yml", + "Migrated `variables` section of acquia-pipelines.yml to .gitlab-ci.yml", ]); } else { $this->io->info([ - "Checked acquia-pipeline.yml file for `variables` section", + "Checked acquia-pipeline.yml file for `variables` section", ]); } } @@ -171,48 +171,48 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $eventsMap = [ - 'build' => [ - 'skip' => [ - 'composer install' => [ - 'message' => 'Code Studio AutoDevOps will run `composer install` by default. Skipping migration of this command in your acquia-pipelines.yml file:', - 'prompt' => false, - ], - '${BLT_DIR}' => [ - 'message' => 'Code Studio AutoDevOps will run BLT commands for you by default. Do you want to migrate the following command?', - 'prompt' => true, - ], - ], - 'default_stage' => 'Test Drupal', - 'stage' => [ - 'setup' => 'Build Drupal', - 'npm run build' => 'Build Drupal', - 'validate' => 'Test Drupal', - 'tests' => 'Test Drupal', - 'test' => 'Test Drupal', - 'npm test' => 'Test Drupal', - 'artifact' => 'Deploy Drupal', - 'deploy' => 'Deploy Drupal', - ], - 'needs' => [ - 'Build Code', - 'Manage Secrets', - ], - ], - 'post-deploy' => [ - 'skip' => [ - 'launch_ode' => [ - 'message' => 'Code Studio AutoDevOps will run Launch a new Continuous Delivery Environment (CDE) automatically for new merge requests. Skipping migration of this command in your acquia-pipelines.yml file:', - 'prompt' => false, - ], - ], - 'default_stage' => 'Deploy Drupal', - 'stage' => [ - 'launch_ode' => 'Deploy Drupal', - ], - 'needs' => [ - 'Create artifact from branch', - ], - ], + 'build' => [ + 'skip' => [ + 'composer install' => [ + 'message' => 'Code Studio AutoDevOps will run `composer install` by default. Skipping migration of this command in your acquia-pipelines.yml file:', + 'prompt' => false, + ], + '${BLT_DIR}' => [ + 'message' => 'Code Studio AutoDevOps will run BLT commands for you by default. Do you want to migrate the following command?', + 'prompt' => true, + ], + ], + 'default_stage' => 'Test Drupal', + 'stage' => [ + 'setup' => 'Build Drupal', + 'npm run build' => 'Build Drupal', + 'validate' => 'Test Drupal', + 'tests' => 'Test Drupal', + 'test' => 'Test Drupal', + 'npm test' => 'Test Drupal', + 'artifact' => 'Deploy Drupal', + 'deploy' => 'Deploy Drupal', + ], + 'needs' => [ + 'Build Code', + 'Manage Secrets', + ], + ], + 'post-deploy' => [ + 'skip' => [ + 'launch_ode' => [ + 'message' => 'Code Studio AutoDevOps will run Launch a new Continuous Delivery Environment (CDE) automatically for new merge requests. Skipping migration of this command in your acquia-pipelines.yml file:', + 'prompt' => false, + ], + ], + 'default_stage' => 'Deploy Drupal', + 'stage' => [ + 'launch_ode' => 'Deploy Drupal', + ], + 'needs' => [ + 'Create artifact from branch', + ], + ], ]; // phpcs:enable @@ -241,8 +241,8 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array } } else { $this->io->note([ - $messageConfig['message'], - $command, + $messageConfig['message'], + $command, ]); } break; @@ -272,11 +272,11 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array } $gitlabCiFileContents = array_merge($gitlabCiFileContents, $codeStudioJobs); $this->io->success([ - "Completed migration of the $eventName step in your acquia-pipelines.yml file", + "Completed migration of the $eventName step in your acquia-pipelines.yml file", ]); } else { $this->io->writeln([ - "acquia-pipeline.yml file does not contain $eventName step to migrate", + "acquia-pipeline.yml file does not contain $eventName step to migrate", ]); } } diff --git a/src/Command/CodeStudio/CodeStudioWizardCommand.php b/src/Command/CodeStudio/CodeStudioWizardCommand.php index 1e1c4ded8..500d7225b 100644 --- a/src/Command/CodeStudio/CodeStudioWizardCommand.php +++ b/src/Command/CodeStudio/CodeStudioWizardCommand.php @@ -52,9 +52,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int switch ($projectSelected) { case "Drupal_project": $phpVersions = [ - 'PHP_version_8.1' => "8.1", - 'PHP_version_8.2' => "8.2", - 'PHP_version_8.3' => "8.3", + 'PHP_version_8.1' => "8.1", + 'PHP_version_8.2' => "8.2", + 'PHP_version_8.3' => "8.3", ]; $project = $this->io->choice('Select a PHP version', array_values($phpVersions), "8.1"); $project = array_search($project, $phpVersions, true); @@ -62,8 +62,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int break; case "Node_project": $nodeVersions = [ - 'NODE_version_18.17.1' => "18.17.1", - 'NODE_version_20.5.1' => "20.5.1", + 'NODE_version_18.17.1' => "18.17.1", + 'NODE_version_20.5.1' => "20.5.1", ]; $project = $this->io->choice('Select a NODE version', array_values($nodeVersions), "18.17.1"); $project = array_search($project, $nodeVersions, true); @@ -82,17 +82,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $appUuid, $account, [ - "deploy to non-prod", + "deploy to non-prod", // Add SSH key to git repository. - "add ssh key to git", + "add ssh key to git", // Add SSH key to non-production environments. - "add ssh key to non-prod", + "add ssh key to non-prod", // Add a CD environment. - "add an environment", + "add an environment", // Delete a CD environment. - "delete an environment", + "delete an environment", // Manage environment variables on a non-production environment. - "administer environment variables on non-prod", + "administer environment variables on non-prod", ] ); $this->setGitLabProjectDescription($appUuid); @@ -102,12 +102,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $project = $this->determineGitLabProject($cloudApplication); $this->io->writeln([ - "", - "This command will configure the Code Studio project {$project['path_with_namespace']} for automatic deployment to the", - "Acquia Cloud Platform application {$cloudApplication->name} ($appUuid)", - "using credentials (API Token and SSH Key) belonging to {$account->mail}.", - "", - "If the {$account->mail} Cloud account is deleted in the future, this Code Studio project will need to be re-configured.", + "", + "This command will configure the Code Studio project {$project['path_with_namespace']} for automatic deployment to the", + "Acquia Cloud Platform application {$cloudApplication->name} ($appUuid)", + "using credentials (API Token and SSH Key) belonging to {$account->mail}.", + "", + "If the {$account->mail} Cloud account is deleted in the future, this Code Studio project will need to be re-configured.", ]); $answer = $this->io->confirm('Do you want to continue?'); if (!$answer) { @@ -124,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int break; case "Node_project": $parameters = [ - 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', + 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', ]; $client = $this->getGitLabClient(); $client->projects()->update($project['id'], $parameters); @@ -133,14 +133,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $this->io->success([ - "Successfully configured the Code Studio project!", - "This project will now use Acquia's Drupal optimized AutoDevOps to build, test, and deploy your code automatically to Acquia Cloud Platform via CI/CD pipelines.", - "You can visit it here:", - $project['web_url'], - "", - "Next, you should use git to push code to your Code Studio project. E.g.,", - " git remote add codestudio {$project['http_url_to_repo']}", - " git push codestudio", + "Successfully configured the Code Studio project!", + "This project will now use Acquia's Drupal optimized AutoDevOps to build, test, and deploy your code automatically to Acquia Cloud Platform via CI/CD pipelines.", + "You can visit it here:", + $project['web_url'], + "", + "Next, you should use git to push code to your Code Studio project. E.g.,", + " git remote add codestudio {$project['http_url_to_repo']}", + " git push codestudio", ]); $this->io->note(["If the {$account->mail} Cloud account is deleted in the future, this Code Studio project will need to be re-configured."]); @@ -181,8 +181,8 @@ private function getGitLabProjectAccessTokenByName(array $project, string $name) private function getListOfProjectType(): ?array { $array = [ - 'Drupal_project', - 'Node_project', + 'Drupal_project', + 'Node_project', ]; return $array; } @@ -200,10 +200,10 @@ private function createProjectAccessToken(array $project, string $projectAccessT $this->checklist->addItem("Creating access token named $projectAccessTokenName"); $projectAccessToken = $this->gitLabClient->projects() ->createProjectAccessToken($project['id'], [ - 'expires_at' => new DateTime('+365 days'), - 'name' => $projectAccessTokenName, - 'scopes' => ['api', 'write_repository'], - ]); + 'expires_at' => new DateTime('+365 days'), + 'name' => $projectAccessTokenName, + 'scopes' => ['api', 'write_repository'], + ]); $this->checklist->completePreviousItem(); return $projectAccessToken['token']; } @@ -267,17 +267,17 @@ private function createScheduledPipeline(array $project): void $this->checklist->addItem("Creating scheduled pipeline $scheduledPipelineDescription"); $pipeline = $this->gitLabClient->schedules()->create($project['id'], [ // Every Thursday at midnight. - 'cron' => '0 0 * * 4', - 'description' => $scheduledPipelineDescription, - 'ref' => $project['default_branch'], + 'cron' => '0 0 * * 4', + 'description' => $scheduledPipelineDescription, + 'ref' => $project['default_branch'], ]); $this->gitLabClient->schedules()->addVariable($project['id'], $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', - 'value' => 'true', + 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', + 'value' => 'true', ]); $this->gitLabClient->schedules()->addVariable($project['id'], $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', - 'value' => 'true', + 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', + 'value' => 'true', ]); } else { $this->checklist->addItem("Scheduled pipeline named $scheduledPipelineDescription already exists"); diff --git a/src/Command/CommandBase.php b/src/Command/CommandBase.php index 51b7b219d..0231b8746 100644 --- a/src/Command/CommandBase.php +++ b/src/Command/CommandBase.php @@ -134,8 +134,8 @@ public function appendHelp(string $helpText): void protected static function getUuidRegexConstraint(): Regex { return new Regex([ - 'message' => 'This is not a valid UUID.', - 'pattern' => '/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i', + 'message' => 'This is not a valid UUID.', + 'pattern' => '/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i', ]); } @@ -266,13 +266,13 @@ public function run(InputInterface $input, OutputInterface $output): int return $exitCode; } $eventProperties = [ - 'app_version' => $this->getApplication()->getVersion(), - 'arguments' => $input->getArguments(), - 'exit_code' => $exitCode, - 'options' => $input->getOptions(), - 'os_name' => OsInfo::os(), - 'os_version' => OsInfo::version(), - 'platform' => OsInfo::family(), + 'app_version' => $this->getApplication()->getVersion(), + 'arguments' => $input->getArguments(), + 'exit_code' => $exitCode, + 'options' => $input->getOptions(), + 'os_name' => OsInfo::os(), + 'os_version' => OsInfo::version(), + 'platform' => OsInfo::family(), ]; Amplitude::getInstance()->queueEvent('Ran command', $eventProperties); @@ -392,8 +392,8 @@ protected function promptChooseLogs(): object|array|null { $logs = array_map(static function (mixed $logType, mixed $logLabel): array { return [ - 'label' => $logLabel, - 'type' => $logType, + 'label' => $logLabel, + 'type' => $logType, ]; }, array_keys(LogstreamManager::AVAILABLE_TYPES), LogstreamManager::AVAILABLE_TYPES); return $this->promptChooseFromObjectsOrArrays( @@ -473,17 +473,17 @@ protected function rsyncFiles(string $sourceDir, string $destinationDir, ?callab { $this->localMachineHelper->checkRequiredBinariesExist(['rsync']); $command = [ - 'rsync', + 'rsync', // -a archive mode; same as -rlptgoD. // -z compress file data during the transfer. // -v increase verbosity. // -P show progress during transfer. // -h output numbers in a human-readable format. // -e specify the remote shell to use. - '-avPhze', - 'ssh -o StrictHostKeyChecking=no', - $sourceDir . '/', - $destinationDir, + '-avPhze', + 'ssh -o StrictHostKeyChecking=no', + $sourceDir . '/', + $destinationDir, ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { @@ -656,9 +656,9 @@ protected function getLocalGitCommitHash(): string { $this->localMachineHelper->checkRequiredBinariesExist(['git']); $process = $this->localMachineHelper->execute([ - 'git', - 'rev-parse', - 'HEAD', + 'git', + 'rev-parse', + 'HEAD', ], null, $this->dir, false); if (!$process->isSuccessful()) { @@ -941,10 +941,10 @@ protected function getCloudApplicationUuidFromBltYaml(): ?string public static function validateUuid(string $uuid): string { $violations = Validation::createValidator()->validate($uuid, [ - new Length([ - 'value' => 36, - ]), - self::getUuidRegexConstraint(), + new Length([ + 'value' => 36, + ]), + self::getUuidRegexConstraint(), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -1039,9 +1039,9 @@ protected function getCloudEnvironment(string $environmentId): EnvironmentRespon public static function validateEnvironmentAlias(string $alias): string { $violations = Validation::createValidator()->validate($alias, [ - new Length(['min' => 5]), - new NotBlank(), - new Regex(['pattern' => '/.+\..+/', 'message' => 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]']), + new Length(['min' => 5]), + new NotBlank(), + new Regex(['pattern' => '/.+\..+/', 'message' => 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]']), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -1488,8 +1488,8 @@ protected function reAuthenticate(string $apiKey, string $apiSecret, ?string $ba // this is being run as a sub-command. // @see https://github.com/acquia/cli/issues/403 $this->cloudApiClientService->setConnector(new Connector([ - 'key' => $apiKey, - 'secret' => $apiSecret, + 'key' => $apiKey, + 'secret' => $apiSecret, ], $baseUri, $accountsUri)); } @@ -1563,11 +1563,11 @@ protected function runDrushCacheClear(Closure $outputCallback, Checklist $checkl $checklist->addItem('Clearing Drupal caches via Drush'); // @todo Add support for Drush 8. $process = $this->localMachineHelper->execute([ - 'drush', - 'cache:rebuild', - '--yes', - '--no-interaction', - '--verbose', + 'drush', + 'cache:rebuild', + '--yes', + '--no-interaction', + '--verbose', ], $outputCallback, $this->dir, false); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to rebuild Drupal caches via Drush. {message}', ['message' => $process->getErrorOutput()]); @@ -1583,11 +1583,11 @@ protected function runDrushSqlSanitize(Closure $outputCallback, Checklist $check if ($this->getDrushDatabaseConnectionStatus()) { $checklist->addItem('Sanitizing database via Drush'); $process = $this->localMachineHelper->execute([ - 'drush', - 'sql:sanitize', - '--yes', - '--no-interaction', - '--verbose', + 'drush', + 'sql:sanitize', + '--yes', + '--no-interaction', + '--verbose', ], $outputCallback, $this->dir, false); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to sanitize Drupal database via Drush. {message}', ['message' => $process->getErrorOutput()]); @@ -1603,9 +1603,9 @@ protected function runDrushSqlSanitize(Closure $outputCallback, Checklist $check private function composerInstall(?callable $outputCallback): void { $process = $this->localMachineHelper->execute([ - 'composer', - 'install', - '--no-interaction', + 'composer', + 'install', + '--no-interaction', ], $outputCallback, $this->dir, false); if (!$process->isSuccessful()) { throw new AcquiaCliException( @@ -1622,11 +1622,11 @@ protected function getDrushDatabaseConnectionStatus(Closure $outputCallback = nu } if ($this->localMachineHelper->commandExists('drush')) { $process = $this->localMachineHelper->execute([ - 'drush', - 'status', - '--fields=db-status,drush-version', - '--format=json', - '--no-interaction', + 'drush', + 'status', + '--fields=db-status,drush-version', + '--format=json', + '--no-interaction', ], $outputCallback, $this->dir, false); if ($process->isSuccessful()) { $drushStatusReturnOutput = json_decode($process->getOutput(), true); @@ -1690,9 +1690,9 @@ protected function determineApiKey(): string private function validateApiKey(mixed $key): string { $violations = Validation::createValidator()->validate($key, [ - new Length(['min' => 10]), - new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), + new Length(['min' => 10]), + new NotBlank(), + new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -1925,8 +1925,8 @@ protected function validateRequiredCloudPermissions(Client $acquiaCloudClient, ? foreach ($requiredPermissions as $name) { if (!array_key_exists($name, $keyedPermissions)) { throw new AcquiaCliException("The Acquia Cloud Platform account {account} does not have the required '{name}' permission. Add the permissions to this user or use an API Token belonging to a different Acquia Cloud Platform user.", [ - 'account' => $account->mail, - 'name' => $name, + 'account' => $account->mail, + 'name' => $name, ]); } } @@ -1935,10 +1935,10 @@ protected function validateRequiredCloudPermissions(Client $acquiaCloudClient, ? protected function validatePhpVersion(string $version): string { $violations = Validation::createValidator()->validate($version, [ - new Length(['min' => 3]), - new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), - new Regex(['pattern' => '/[0-9]{1}\.[0-9]{1}/', 'message' => 'The value must be in the format "x.y"']), + new Length(['min' => 3]), + new NotBlank(), + new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), + new Regex(['pattern' => '/[0-9]{1}\.[0-9]{1}/', 'message' => 'The value must be in the format "x.y"']), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/DocsCommand.php b/src/Command/DocsCommand.php index 4512bafac..d4167c4da 100644 --- a/src/Command/DocsCommand.php +++ b/src/Command/DocsCommand.php @@ -24,78 +24,78 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { $acquiaProducts = [ - 'Acquia CLI' => [ - 'alias' => ['cli', 'acli'], - 'url' => 'acquia-cli', - ], - 'Acquia CMS' => [ - 'alias' => ['acquia_cms', 'acms'], - 'url' => 'acquia-cms', - ], - 'Acquia DAM Classic' => [ - 'alias' => ['dam', 'acquia_dam', 'dam_classic', 'acquiadam', 'damclassic'], - 'url' => 'dam', - ], - 'Acquia Migrate Accelerate' => [ - 'alias' => ['acquia-migrate-accelerate', 'ama'], - 'url' => 'acquia-migrate-accelerate', - ], - 'BLT' => [ - 'alias' => ['blt'], - 'url' => 'blt', - ], - 'Campaign Factory' => [ - 'alias' => ['campaign-factory', 'campaign_factory', 'campaignfactory'], - 'url' => 'campaign-factory', - ], - 'Campaign Studio' => [ - 'alias' => ['campaign-studio', 'campaignstudio'], - 'url' => 'campaign-studio', - ], - 'Cloud IDE' => [ - 'alias' => ['ide', 'cloud_ide', 'cloud-ide'], - 'url' => 'ide', - ], - 'Cloud Platform' => [ - 'alias' => ['cloud-platform', 'acquiacloud', 'acquia_cloud', 'acquia-cloud', 'cloud'], - 'url' => 'cloud-platform', - ], - 'Code Studio' => [ - 'alias' => ['code_studio', 'codestudio', 'cs'], - 'url' => 'code-studio', - ], - 'Content Hub' => [ - 'alias' => ['contenthub', 'ch'], - 'url' => 'contenthub', - ], - 'Customer Data Platform' => [ - 'alias' => ['customer-data-platform', 'cdp'], - 'url' => 'customer-data-platform', - ], - 'Edge' => [ - 'alias' => ['edge', 'cloudedge'], - 'url' => 'edge', - ], - 'Personalization' => [ - 'alias' => ['personalization'], - 'url' => 'personalization', - ], - 'Search' => [ - 'alias' => ['search', 'acquia-search'], - 'url' => 'acquia-search', - ], - 'Shield' => [ - 'alias' => ['shield'], - 'url' => 'shield', - ], - 'Site Factory' => [ - 'alias' => ['site-factory', 'acsf'], - 'url' => 'site-factory', - ], - 'Site Studio' => [ - 'alias' => ['site-studio', 'cohesion'], - 'url' => 'site-studio', - ], + 'Acquia CLI' => [ + 'alias' => ['cli', 'acli'], + 'url' => 'acquia-cli', + ], + 'Acquia CMS' => [ + 'alias' => ['acquia_cms', 'acms'], + 'url' => 'acquia-cms', + ], + 'Acquia DAM Classic' => [ + 'alias' => ['dam', 'acquia_dam', 'dam_classic', 'acquiadam', 'damclassic'], + 'url' => 'dam', + ], + 'Acquia Migrate Accelerate' => [ + 'alias' => ['acquia-migrate-accelerate', 'ama'], + 'url' => 'acquia-migrate-accelerate', + ], + 'BLT' => [ + 'alias' => ['blt'], + 'url' => 'blt', + ], + 'Campaign Factory' => [ + 'alias' => ['campaign-factory', 'campaign_factory', 'campaignfactory'], + 'url' => 'campaign-factory', + ], + 'Campaign Studio' => [ + 'alias' => ['campaign-studio', 'campaignstudio'], + 'url' => 'campaign-studio', + ], + 'Cloud IDE' => [ + 'alias' => ['ide', 'cloud_ide', 'cloud-ide'], + 'url' => 'ide', + ], + 'Cloud Platform' => [ + 'alias' => ['cloud-platform', 'acquiacloud', 'acquia_cloud', 'acquia-cloud', 'cloud'], + 'url' => 'cloud-platform', + ], + 'Code Studio' => [ + 'alias' => ['code_studio', 'codestudio', 'cs'], + 'url' => 'code-studio', + ], + 'Content Hub' => [ + 'alias' => ['contenthub', 'ch'], + 'url' => 'contenthub', + ], + 'Customer Data Platform' => [ + 'alias' => ['customer-data-platform', 'cdp'], + 'url' => 'customer-data-platform', + ], + 'Edge' => [ + 'alias' => ['edge', 'cloudedge'], + 'url' => 'edge', + ], + 'Personalization' => [ + 'alias' => ['personalization'], + 'url' => 'personalization', + ], + 'Search' => [ + 'alias' => ['search', 'acquia-search'], + 'url' => 'acquia-search', + ], + 'Shield' => [ + 'alias' => ['shield'], + 'url' => 'shield', + ], + 'Site Factory' => [ + 'alias' => ['site-factory', 'acsf'], + 'url' => 'site-factory', + ], + 'Site Studio' => [ + 'alias' => ['site-studio', 'cohesion'], + 'url' => 'site-studio', + ], ]; // If user has provided any acquia product in command. diff --git a/src/Command/Email/ConfigurePlatformEmailCommand.php b/src/Command/Email/ConfigurePlatformEmailCommand.php index 7f7a7e44e..368c60707 100644 --- a/src/Command/Email/ConfigurePlatformEmailCommand.php +++ b/src/Command/Email/ConfigurePlatformEmailCommand.php @@ -55,18 +55,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int $client = $this->cloudApiClientService->getClient(); $subscription = $this->determineCloudSubscription(); $client->request('post', "/subscriptions/$subscription->uuid/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ]); $domainUuid = $this->fetchDomainUuid($client, $subscription, $baseDomain); $this->io->success([ - "Great! You've registered the domain $baseDomain to subscription $subscription->name.", - "We will create a file with the DNS records for your newly registered domain", - "Provide these records to your DNS provider", - "After you've done this, continue to domain verification.", + "Great! You've registered the domain $baseDomain to subscription $subscription->name.", + "We will create a file with the DNS records for your newly registered domain", + "Provide these records to your DNS provider", + "After you've done this, continue to domain verification.", ]); $fileFormat = $this->io->choice('Would you like your DNS records in BIND Zone File, JSON, or YAML format?', ['BIND Zone File', 'YAML', 'JSON'], 'BIND Zone File'); $this->createDnsText($client, $subscription, $baseDomain, $domainUuid, $fileFormat); @@ -330,8 +330,8 @@ private function checkIfDomainVerified( private function determineDomain(): string { $domain = $this->io->ask("What's the domain name you'd like to register?", '', Closure::fromCallable([ - $this, - 'validateUrl', + $this, + 'validateUrl', ])); $domainParts = parse_url($domain); diff --git a/src/Command/Email/EmailInfoForSubscriptionCommand.php b/src/Command/Email/EmailInfoForSubscriptionCommand.php index f4b6fcd3e..9f01e51c6 100644 --- a/src/Command/Email/EmailInfoForSubscriptionCommand.php +++ b/src/Command/Email/EmailInfoForSubscriptionCommand.php @@ -110,37 +110,37 @@ private function writeDomainsToTables(OutputInterface $output, SubscriptionRespo } $allDomainsTable->addRow([ - $domain->domain_name, - $domain->uuid, - $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, + $domain->domain_name, + $domain->uuid, + $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, ]); $writerAllDomains->insertOne([ - $domain->domain_name, - $domain->uuid, - $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, + $domain->domain_name, + $domain->uuid, + $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, ]); foreach ($domain->dns_records as $index => $record) { if ($index === 0) { $writerAllDomainsDnsHealth->insertOne([ - $domain->domain_name, - $domain->uuid, - $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, - $record->name, - $record->type, - $record->value, - $record->health->details, + $domain->domain_name, + $domain->uuid, + $this->showHumanReadableStatus($domain->health->code) . ' - ' . $domain->health->code, + $record->name, + $record->type, + $record->value, + $record->health->details, ]); } else { $writerAllDomainsDnsHealth->insertOne([ - '', - '', - '', - $record->name, - $record->type, - $record->value, - $record->health->details, + '', + '', + '', + $record->name, + $record->type, + $record->value, + $record->health->details, ]); } } @@ -204,17 +204,17 @@ private function renderApplicationAssociations(OutputInterface $output, Client $ if (count($appDomains)) { foreach ($appDomains as $domain) { $appsDomainsTable->addRow([ - $domain->domain_name, - var_export($domain->flags->associated, true), + $domain->domain_name, + var_export($domain->flags->associated, true), ]); $writerAppsDomains->insertOne([$app->name, $domain->domain_name, var_export($domain->flags->associated, true)]); } } else { $appsDomainsTable->addRow([new TableCell("No domains eligible for association.", [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'yellow', - ]), + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'yellow', + ]), ]), ]); $writerAppsDomains->insertOne([$app->name, 'No domains eligible for association', '']); diff --git a/src/Command/Env/EnvCopyCronCommand.php b/src/Command/Env/EnvCopyCronCommand.php index d6b6923a8..4c000d85b 100644 --- a/src/Command/Env/EnvCopyCronCommand.php +++ b/src/Command/Env/EnvCopyCronCommand.php @@ -73,11 +73,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int // when environment is provisioned. if (!$cron->flags->system) { $cronFrequency = implode(' ', [ - $cron->minute, - $cron->hour, - $cron->dayMonth, - $cron->month, - $cron->dayWeek, + $cron->minute, + $cron->hour, + $cron->dayMonth, + $cron->month, + $cron->dayWeek, ]); $this->io->info('Copying the cron task "' . $cron->label . '" from ' . $sourceEnvId . ' to ' . $destEnvId); @@ -93,10 +93,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->io->error('There was some error while copying the cron task "' . $cron->label . '"'); // Log the error for debugging purpose. $this->logger->debug('Error @error while copying the cron task @cron from @source env to @dest env', [ - '@cron' => $cron->label, - '@dest' => $destEnvId, - '@error' => $e->getMessage(), - '@source' => $sourceEnvId, + '@cron' => $cron->label, + '@dest' => $destEnvId, + '@error' => $e->getMessage(), + '@source' => $sourceEnvId, ]); return 1; } diff --git a/src/Command/Env/EnvCreateCommand.php b/src/Command/Env/EnvCreateCommand.php index 3eb49463c..19cf133a6 100644 --- a/src/Command/Env/EnvCreateCommand.php +++ b/src/Command/Env/EnvCreateCommand.php @@ -57,8 +57,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (isset($environment)) { $this->output->writeln([ - '', - "Your CDE URL: domains[0]}>{$environment->domains[0]}", + '', + "Your CDE URL: domains[0]}>{$environment->domains[0]}", ]); } }; diff --git a/src/Command/Env/EnvDeleteCommand.php b/src/Command/Env/EnvDeleteCommand.php index 25719c9c1..e4c8488f9 100644 --- a/src/Command/Env/EnvDeleteCommand.php +++ b/src/Command/Env/EnvDeleteCommand.php @@ -33,7 +33,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $environmentsResource->delete($environment->uuid); $this->io->success([ - "The {$environment->label} environment is being deleted", + "The {$environment->label} environment is being deleted", ]); return Command::SUCCESS; diff --git a/src/Command/Env/EnvMirrorCommand.php b/src/Command/Env/EnvMirrorCommand.php index e3860ff7e..12592a767 100644 --- a/src/Command/Env/EnvMirrorCommand.php +++ b/src/Command/Env/EnvMirrorCommand.php @@ -92,9 +92,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $this->io->success([ - "Done! {$destinationEnvironment->label} now matches {$sourceEnvironment->label}", - "You can visit it here:", - "https://" . $destinationEnvironment->domains[0], + "Done! {$destinationEnvironment->label} now matches {$sourceEnvironment->label}", + "You can visit it here:", + "https://" . $destinationEnvironment->domains[0], ]); return Command::SUCCESS; @@ -130,9 +130,9 @@ private function mirrorCode(Client $acquiaCloudClient, mixed $destinationEnviron $this->checklist->addItem("Initiating code switch"); $outputCallback('out', "Switching to {$sourceEnvironment->vcs->path}"); $codeCopyResponse = $acquiaCloudClient->request('post', "/environments/$destinationEnvironmentUuid/code/actions/switch", [ - 'form_params' => [ - 'branch' => $sourceEnvironment->vcs->path, - ], + 'form_params' => [ + 'branch' => $sourceEnvironment->vcs->path, + ], ]); $codeCopyResponse->links = $codeCopyResponse->_links; $this->checklist->completePreviousItem(); diff --git a/src/Command/Ide/IdeCommandBase.php b/src/Command/Ide/IdeCommandBase.php index f3204ccc3..fbeab7c18 100644 --- a/src/Command/Ide/IdeCommandBase.php +++ b/src/Command/Ide/IdeCommandBase.php @@ -42,9 +42,9 @@ protected function promptIdeChoice( protected function startService(string $service): void { $process = $this->localMachineHelper->execute([ - 'supervisorctl', - 'start', - $service, + 'supervisorctl', + 'start', + $service, ], null, null, false); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to start ' . $service . ' in the IDE: {error}', ['error' => $process->getErrorOutput()]); @@ -57,9 +57,9 @@ protected function startService(string $service): void protected function stopService(string $service): void { $process = $this->localMachineHelper->execute([ - 'supervisorctl', - 'stop', - $service, + 'supervisorctl', + 'stop', + $service, ], null, null, false); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to stop ' . $service . ' in the IDE: {error}', ['error' => $process->getErrorOutput()]); @@ -72,9 +72,9 @@ protected function stopService(string $service): void protected function restartService(string $service): void { $process = $this->localMachineHelper->execute([ - 'supervisorctl', - 'restart', - $service, + 'supervisorctl', + 'restart', + $service, ], null, null, false); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to restart ' . $service . ' in the IDE: {error}', ['error' => $process->getErrorOutput()]); diff --git a/src/Command/Ide/IdeCreateCommand.php b/src/Command/Ide/IdeCreateCommand.php index 2c106e5cd..f62933d6b 100644 --- a/src/Command/Ide/IdeCreateCommand.php +++ b/src/Command/Ide/IdeCreateCommand.php @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int public function validateIdeLabel(string $label): string { $violations = Validation::createValidator()->validate($label, [ - new Regex(['pattern' => '/^[\w\' ]+$/', 'message' => 'Use only letters, numbers, and spaces']), + new Regex(['pattern' => '/^[\w\' ]+$/', 'message' => 'Use only letters, numbers, and spaces']), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ide/IdeListCommand.php b/src/Command/Ide/IdeListCommand.php index dfa5e9bac..37bd43a86 100644 --- a/src/Command/Ide/IdeListCommand.php +++ b/src/Command/Ide/IdeListCommand.php @@ -36,10 +36,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table->setHeaders(['IDEs']); foreach ($applicationIdes as $ide) { $table->addRows([ - ["{$ide->label} ({$ide->owner->mail})"], - ["IDE URL: links->ide->href}>{$ide->links->ide->href}"], - ["Web URL: links->web->href}>{$ide->links->web->href}"], - new TableSeparator(), + ["{$ide->label} ({$ide->owner->mail})"], + ["IDE URL: links->ide->href}>{$ide->links->ide->href}"], + ["Web URL: links->web->href}>{$ide->links->web->href}"], + new TableSeparator(), ]); } $table->render(); diff --git a/src/Command/Ide/IdeListMineCommand.php b/src/Command/Ide/IdeListMineCommand.php index cb7fb3f87..a5a1325f3 100644 --- a/src/Command/Ide/IdeListMineCommand.php +++ b/src/Command/Ide/IdeListMineCommand.php @@ -36,13 +36,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $applicationUrl = str_replace('/api', '/a', $application->links->self->href); $table->addRows([ - ["$ide->label"], - ["UUID: $ide->uuid"], - ["Application: $application->name"], - ["Subscription: {$application->subscription->name}"], - ["IDE URL: links->ide->href}>{$ide->links->ide->href}"], - ["Web URL: links->web->href}>{$ide->links->web->href}"], - new TableSeparator(), + ["$ide->label"], + ["UUID: $ide->uuid"], + ["Application: $application->name"], + ["Subscription: {$application->subscription->name}"], + ["IDE URL: links->ide->href}>{$ide->links->ide->href}"], + ["Web URL: links->web->href}>{$ide->links->web->href}"], + new TableSeparator(), ]); } $table->render(); diff --git a/src/Command/Ide/IdeServiceRestartCommand.php b/src/Command/Ide/IdeServiceRestartCommand.php index c6a0eee34..58e5dee2d 100644 --- a/src/Command/Ide/IdeServiceRestartCommand.php +++ b/src/Command/Ide/IdeServiceRestartCommand.php @@ -34,12 +34,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->validateService($service); $serviceNameMap = [ - 'apache' => 'apache2', - 'apache2' => 'apache2', - 'mysql' => 'mysqld', - 'mysqld' => 'mysqld', - 'php' => 'php-fpm', - 'php-fpm' => 'php-fpm', + 'apache' => 'apache2', + 'apache2' => 'apache2', + 'mysql' => 'mysqld', + 'mysqld' => 'mysqld', + 'php' => 'php-fpm', + 'php-fpm' => 'php-fpm', ]; $output->writeln("Restarting $service..."); $serviceName = $serviceNameMap[$service]; @@ -52,10 +52,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ - new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], - 'message' => 'Specify a valid service name: php, apache, or mysql', - ]), + new Choice([ + 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'message' => 'Specify a valid service name: php, apache, or mysql', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ide/IdeServiceStartCommand.php b/src/Command/Ide/IdeServiceStartCommand.php index 71a5e19b0..0e1e4bf4e 100644 --- a/src/Command/Ide/IdeServiceStartCommand.php +++ b/src/Command/Ide/IdeServiceStartCommand.php @@ -34,12 +34,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->validateService($service); $serviceNameMap = [ - 'apache' => 'apache2', - 'apache2' => 'apache2', - 'mysql' => 'mysqld', - 'mysqld' => 'mysqld', - 'php' => 'php-fpm', - 'php-fpm' => 'php-fpm', + 'apache' => 'apache2', + 'apache2' => 'apache2', + 'mysql' => 'mysqld', + 'mysqld' => 'mysqld', + 'php' => 'php-fpm', + 'php-fpm' => 'php-fpm', ]; $output->writeln("Starting $service..."); $serviceName = $serviceNameMap[$service]; @@ -52,10 +52,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ - new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], - 'message' => 'Specify a valid service name: php, apache, or mysql', - ]), + new Choice([ + 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'message' => 'Specify a valid service name: php, apache, or mysql', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ide/IdeServiceStopCommand.php b/src/Command/Ide/IdeServiceStopCommand.php index 039015a1d..ae93ff415 100644 --- a/src/Command/Ide/IdeServiceStopCommand.php +++ b/src/Command/Ide/IdeServiceStopCommand.php @@ -34,12 +34,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->validateService($service); $serviceNameMap = [ - 'apache' => 'apache2', - 'apache2' => 'apache2', - 'mysql' => 'mysqld', - 'mysqld' => 'mysqld', - 'php' => 'php-fpm', - 'php-fpm' => 'php-fpm', + 'apache' => 'apache2', + 'apache2' => 'apache2', + 'mysql' => 'mysqld', + 'mysqld' => 'mysqld', + 'php' => 'php-fpm', + 'php-fpm' => 'php-fpm', ]; $output->writeln("Stopping $service..."); $serviceName = $serviceNameMap[$service]; @@ -52,10 +52,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ - new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], - 'message' => 'Specify a valid service name: php, apache, or mysql', - ]), + new Choice([ + 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'message' => 'Specify a valid service name: php, apache, or mysql', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ide/IdeShareCommand.php b/src/Command/Ide/IdeShareCommand.php index f01240c89..5ebc67658 100644 --- a/src/Command/Ide/IdeShareCommand.php +++ b/src/Command/Ide/IdeShareCommand.php @@ -57,8 +57,8 @@ private function getShareCodeFilepaths(): array { if (!isset($this->shareCodeFilepaths)) { $this->shareCodeFilepaths = [ - '/usr/local/share/ide/.sharecode', - '/home/ide/.sharecode', + '/usr/local/share/ide/.sharecode', + '/home/ide/.sharecode', ]; } return $this->shareCodeFilepaths; diff --git a/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php b/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php index f8383b732..f6bbb2f0c 100644 --- a/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php +++ b/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php @@ -37,9 +37,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $account, [ // Add SSH key to git repository. - "add ssh key to git", + "add ssh key to git", // Add SSH key to non-production environments. - "add ssh key to non-prod", + "add ssh key to non-prod", ] ); diff --git a/src/Command/Pull/PullCommandBase.php b/src/Command/Pull/PullCommandBase.php index 84b93117a..f12954456 100644 --- a/src/Command/Pull/PullCommandBase.php +++ b/src/Command/Pull/PullCommandBase.php @@ -100,10 +100,10 @@ public static function getBackupPath(object $environment, DatabaseResponse $data $dbMachineName = 'db' . $database->id; } $filename = implode('-', [ - $environment->name, - $database->name, - $dbMachineName, - $backupResponse->completedAt, + $environment->name, + $database->name, + $dbMachineName, + $backupResponse->completedAt, ]) . '.sql.gz'; return Path::join(sys_get_temp_dir(), $filename); } @@ -182,9 +182,9 @@ private function pullCodeFromCloud(EnvironmentResponse $chosenEnvironment, Closu // @todo Validate that an Acquia remote is configured for this repository. $this->localMachineHelper->checkRequiredBinariesExist(['git']); $this->localMachineHelper->execute([ - 'git', - 'fetch', - '--all', + 'git', + 'fetch', + '--all', ], $outputCallback, $this->dir, false); $this->checkoutBranchFromEnv($chosenEnvironment, $outputCallback); } @@ -196,9 +196,9 @@ private function checkoutBranchFromEnv(EnvironmentResponse $environment, Closure { $this->localMachineHelper->checkRequiredBinariesExist(['git']); $this->localMachineHelper->execute([ - 'git', - 'checkout', - $environment->vcs->path, + 'git', + 'checkout', + $environment->vcs->path, ], $outputCallback, $this->dir, false); } @@ -234,8 +234,8 @@ private function downloadDatabaseBackup( $acquiaCloudClient = $this->cloudApiClientService->getClient(); $acquiaCloudClient->addOption('sink', $localFilepath); $acquiaCloudClient->addOption('curl.options', [ - 'CURLOPT_FILE' => $localFilepath, - 'CURLOPT_RETURNTRANSFER' => false, + 'CURLOPT_FILE' => $localFilepath, + 'CURLOPT_RETURNTRANSFER' => false, ]); $acquiaCloudClient->addOption( 'progress', @@ -352,21 +352,21 @@ private function connectToLocalDatabase(string $dbHost, string $dbUser, string $ } $this->localMachineHelper->checkRequiredBinariesExist(['mysql']); $command = [ - 'mysql', - '--host', - $dbHost, - '--user', - $dbUser, - $dbName, + 'mysql', + '--host', + $dbHost, + '--user', + $dbUser, + $dbName, ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, false, null, ['MYSQL_PWD' => $dbPassword]); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to connect to local database using credentials mysql://{user}:{password}@{host}/{database}. {message}', [ - 'database' => $dbName, - 'host' => $dbHost, - 'message' => $process->getErrorOutput(), - 'password' => $dbPassword, - 'user' => $dbUser, + 'database' => $dbName, + 'host' => $dbHost, + 'message' => $process->getErrorOutput(), + 'password' => $dbPassword, + 'user' => $dbUser, ]); } } @@ -378,15 +378,15 @@ private function dropDbTables(string $dbHost, string $dbUser, string $dbName, st } $this->localMachineHelper->checkRequiredBinariesExist(['mysql']); $command = [ - 'mysql', - '--host', - $dbHost, - '--user', - $dbUser, - $dbName, - '--silent', - '-e', - 'SHOW TABLES;', + 'mysql', + '--host', + $dbHost, + '--user', + $dbUser, + $dbName, + '--silent', + '-e', + 'SHOW TABLES;', ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, false, null, ['MYSQL_PWD' => $dbPassword]); $tables = $this->listTablesQuoted($process->getOutput()); @@ -395,14 +395,14 @@ private function dropDbTables(string $dbHost, string $dbUser, string $dbName, st $tempnam = $this->localMachineHelper->getFilesystem()->tempnam(sys_get_temp_dir(), 'acli_drop_table_', '.sql'); $this->localMachineHelper->getFilesystem()->dumpFile($tempnam, $sql); $command = [ - 'mysql', - '--host', - $dbHost, - '--user', - $dbUser, - $dbName, - '-e', - 'source ' . $tempnam, + 'mysql', + '--host', + $dbHost, + '--user', + $dbUser, + $dbName, + '-e', + 'source ' . $tempnam, ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, false, null, ['MYSQL_PWD' => $dbPassword]); if (!$process->isSuccessful()) { @@ -489,10 +489,10 @@ private function cloneFromCloud(EnvironmentResponse $chosenEnvironment, Closure { $this->localMachineHelper->checkRequiredBinariesExist(['git']); $command = [ - 'git', - 'clone', - $chosenEnvironment->vcs->url, - $this->dir, + 'git', + 'clone', + $chosenEnvironment->vcs->url, + $this->dir, ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL), null, ['GIT_SSH_COMMAND' => 'ssh -o StrictHostKeyChecking=no']); $this->checkoutBranchFromEnv($chosenEnvironment, $outputCallback); @@ -567,9 +567,9 @@ private function printDatabaseBackupInfo( $dateFormatted = date("D M j G:i:s T Y", strtotime($backupResponse->completedAt)); $webLink = "https://cloud.acquia.com/a/environments/{$sourceEnvironment->uuid}/databases"; $messages = [ - "Using a database backup that is $hoursInterval hours old. Backup #$backupResponse->id was created at {$dateFormatted}.", - "You can view your backups here: $webLink", - "To generate a new backup, re-run this command with the --on-demand option.", + "Using a database backup that is $hoursInterval hours old. Backup #$backupResponse->id was created at {$dateFormatted}.", + "You can view your backups here: $webLink", + "To generate a new backup, re-run this command with the --on-demand option.", ]; if ($hoursInterval > 24) { $this->io->warning($messages); diff --git a/src/Command/Push/PushArtifactCommand.php b/src/Command/Push/PushArtifactCommand.php index de9ccbdf6..9477ef84b 100644 --- a/src/Command/Push/PushArtifactCommand.php +++ b/src/Command/Push/PushArtifactCommand.php @@ -101,12 +101,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $destinationGitUrlsString = implode(',', $destinationGitUrls); $refType = $this->input->getOption('destination-git-tag') ? 'tag' : 'branch'; $this->io->note([ - "Acquia CLI will:", - "- git clone $sourceGitBranch from $destinationGitUrls[0]", - "- Compile the contents of $this->dir into an artifact in a temporary directory", - "- Copy the artifact files into the checked out copy of $sourceGitBranch", - "- Commit changes and push the $destinationGitRef $refType to the following git remote(s):", - " $destinationGitUrlsString", + "Acquia CLI will:", + "- git clone $sourceGitBranch from $destinationGitUrls[0]", + "- Compile the contents of $this->dir into an artifact in a temporary directory", + "- Copy the artifact files into the checked out copy of $sourceGitBranch", + "- Commit changes and push the $destinationGitRef $refType to the following git remote(s):", + " $destinationGitUrlsString", ]); $this->checklist->addItem('Preparing artifact directory'); @@ -180,37 +180,37 @@ private function cloneSourceBranch(Closure $outputCallback, string $artifactDir, $outputCallback('out', "Initializing Git in $artifactDir"); $this->localMachineHelper->checkRequiredBinariesExist(['git']); $process = $this->localMachineHelper->execute([ - 'git', - 'clone', - '--depth=1', - $vcsUrl, - $artifactDir, + 'git', + 'clone', + '--depth=1', + $vcsUrl, + $artifactDir, ], $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException('Failed to clone repository from the Cloud Platform: {message}', ['message' => $process->getErrorOutput()]); } $process = $this->localMachineHelper->execute([ - 'git', - 'fetch', - '--depth=1', - '--update-head-ok', - $vcsUrl, - $vcsPath . ':' . $vcsPath, + 'git', + 'fetch', + '--depth=1', + '--update-head-ok', + $vcsUrl, + $vcsPath . ':' . $vcsPath, ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { // Remote branch does not exist. Just create it locally. This will create // the new branch off of the current commit. $process = $this->localMachineHelper->execute([ - 'git', - 'checkout', - '-b', - $vcsPath, + 'git', + 'checkout', + '-b', + $vcsPath, ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); } else { $process = $this->localMachineHelper->execute([ - 'git', - 'checkout', - $vcsPath, + 'git', + 'checkout', + $vcsPath, ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); } if (!$process->isSuccessful()) { @@ -273,7 +273,7 @@ private function sanitizeArtifact(Closure $outputCallback, string $artifactDir): ->ignoreVCS(false) ->directories() ->in(["$artifactDir/docroot", - "$artifactDir/vendor", + "$artifactDir/vendor", ]) ->name('.git'); $drushDir = "$artifactDir/drush"; @@ -295,15 +295,15 @@ private function sanitizeArtifact(Closure $outputCallback, string $artifactDir): $outputCallback('out', 'Finding other common text files'); $filenames = [ - 'AUTHORS', - 'CHANGELOG', - 'CONDUCT', - 'CONTRIBUTING', - 'INSTALL', - 'MAINTAINERS', - 'PATCHES', - 'TESTING', - 'UPDATE', + 'AUTHORS', + 'CHANGELOG', + 'CONDUCT', + 'CONTRIBUTING', + 'INSTALL', + 'MAINTAINERS', + 'PATCHES', + 'TESTING', + 'UPDATE', ]; $textFileFinder = $this->localMachineHelper->getFinder() ->files() @@ -361,10 +361,10 @@ private function pushArtifact(Closure $outputCallback, string $artifactDir, arra foreach ($vcsUrls as $vcsUrl) { $outputCallback('out', "Pushing changes to Acquia Git ($vcsUrl)"); $args = [ - 'git', - 'push', - $vcsUrl, - $destGitBranch, + 'git', + 'push', + $vcsUrl, + $destGitBranch, ]; $process = $this->localMachineHelper->execute($args, $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { @@ -385,7 +385,7 @@ private function vendorDirs(): array } $this->vendorDirs = [ - 'vendor', + 'vendor', ]; if (file_exists($this->composerJsonPath)) { $composerJson = json_decode($this->localMachineHelper->readFile($this->composerJsonPath), true, 512, JSON_THROW_ON_ERROR); @@ -424,8 +424,8 @@ private function scaffoldFiles(string $artifactDir): array private function validateSourceCode(): void { $requiredPaths = [ - $this->composerJsonPath, - $this->docrootPath, + $this->composerJsonPath, + $this->docrootPath, ]; foreach ($requiredPaths as $requiredPath) { if (!file_exists($requiredPath)) { @@ -483,9 +483,9 @@ private function createTag(mixed $tagName, Closure $outputCallback, string $arti { $this->localMachineHelper->checkRequiredBinariesExist(['git']); $process = $this->localMachineHelper->execute([ - 'git', - 'tag', - $tagName, + 'git', + 'tag', + $tagName, ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException('Failed to create Git tag: {message}', ['message' => $process->getErrorOutput()]); diff --git a/src/Command/Push/PushDatabaseCommand.php b/src/Command/Push/PushDatabaseCommand.php index dd9ee417c..0bfd6609d 100644 --- a/src/Command/Push/PushDatabaseCommand.php +++ b/src/Command/Push/PushDatabaseCommand.php @@ -67,11 +67,11 @@ private function uploadDatabaseDump( $this->logger->debug("Uploading database dump to $remoteFilepath on remote machine"); $this->localMachineHelper->checkRequiredBinariesExist(['rsync']); $command = [ - 'rsync', - '-tDvPhe', - 'ssh -o StrictHostKeyChecking=no', - $localFilepath, - $environment->sshUrl . ':' . $remoteFilepath, + 'rsync', + '-tDvPhe', + 'ssh -o StrictHostKeyChecking=no', + $localFilepath, + $environment->sshUrl . ':' . $remoteFilepath, ]; $process = $this->localMachineHelper->execute($command, $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { diff --git a/src/Command/Remote/AliasesDownloadCommand.php b/src/Command/Remote/AliasesDownloadCommand.php index 89f7a0978..da296796c 100644 --- a/src/Command/Remote/AliasesDownloadCommand.php +++ b/src/Command/Remote/AliasesDownloadCommand.php @@ -66,8 +66,8 @@ protected function promptChooseDrushAliasVersion(): string $this->io->writeln('Drush changed how aliases are defined in Drush 9. Drush 8 aliases are PHP-based and stored in your home directory, while Drush 9+ aliases are YAML-based and stored with your project.'); $question = 'Choose your preferred alias compatibility:'; $choices = [ - '8' => 'Drush 8 / Drupal 7 (PHP)', - '9' => 'Drush 9+ / Drupal 8+ (YAML)', + '8' => 'Drush 8 / Drupal 7 (PHP)', + '9' => 'Drush 9+ / Drupal 8+ (YAML)', ]; return (string) array_search($this->io->choice($question, $choices, '9'), $choices, true); } diff --git a/src/Command/Remote/DrushCommand.php b/src/Command/Remote/DrushCommand.php index dad6feb32..0b8c0bad8 100644 --- a/src/Command/Remote/DrushCommand.php +++ b/src/Command/Remote/DrushCommand.php @@ -40,9 +40,9 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int array_unshift($drushArguments, "--uri=http://$environment->default_domain"); } $drushCommandArguments = [ - "cd /var/www/html/$alias/docroot; ", - 'drush', - implode(' ', $drushArguments), + "cd /var/www/html/$alias/docroot; ", + 'drush', + implode(' ', $drushArguments), ]; return $this->sshHelper->executeCommand($environment->sshUrl, $drushCommandArguments)->getExitCode(); diff --git a/src/Command/Remote/SshCommand.php b/src/Command/Remote/SshCommand.php index 22ba6bee6..cd5841d36 100644 --- a/src/Command/Remote/SshCommand.php +++ b/src/Command/Remote/SshCommand.php @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int throw new AcquiaCliException('Cannot determine environment SSH URL. Check that you have SSH permissions on this environment.'); } $sshCommand = [ - 'cd /var/www/html/' . $alias, + 'cd /var/www/html/' . $alias, ]; $arguments = $input->getArguments(); if (empty($arguments['ssh_command'])) { diff --git a/src/Command/Self/ListCommand.php b/src/Command/Self/ListCommand.php index 224302db6..b8a8c940b 100644 --- a/src/Command/Self/ListCommand.php +++ b/src/Command/Self/ListCommand.php @@ -24,10 +24,10 @@ protected function configure(): void $this ->setName('list') ->setDefinition([ - new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())), - new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), - new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()), - new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()), + new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), ]) ->setDescription('List commands') ->setHelp(<<<'EOF' @@ -69,9 +69,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $helper = new DescriptorHelper(); $helper->describe($output, $this->getApplication(), [ - 'format' => $input->getOption('format'), - 'namespace' => $input->getArgument('namespace'), - 'raw_text' => $input->getOption('raw'), + 'format' => $input->getOption('format'), + 'namespace' => $input->getArgument('namespace'), + 'raw_text' => $input->getOption('raw'), ]); return Command::SUCCESS; diff --git a/src/Command/Self/MakeDocsCommand.php b/src/Command/Self/MakeDocsCommand.php index ad9896a5b..b888f642a 100644 --- a/src/Command/Self/MakeDocsCommand.php +++ b/src/Command/Self/MakeDocsCommand.php @@ -28,7 +28,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$input->getOption('dump')) { $helper->describe($output, $this->getApplication(), [ - 'format' => $input->getOption('format'), + 'format' => $input->getOption('format'), ]); return Command::SUCCESS; } @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->localMachineHelper->getFilesystem()->mkdir($docs_dir); $buffer = new BufferedOutput(); $helper->describe($buffer, $this->getApplication(), [ - 'format' => 'json', + 'format' => 'json', ]); $commands = json_decode($buffer->fetch(), true); $index = []; @@ -47,10 +47,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $filename = $command['name'] . '.json'; $index[] = [ - 'command' => $command['name'], - 'help' => $command['help'], - 'path' => $filename, - 'usage' => $command['usage'][0], + 'command' => $command['name'], + 'help' => $command['help'], + 'path' => $filename, + 'usage' => $command['usage'][0], ]; file_put_contents("$docs_dir/$filename", json_encode($command)); } diff --git a/src/Command/Ssh/SshKeyCommandBase.php b/src/Command/Ssh/SshKeyCommandBase.php index 656ca01b9..55a3a71b3 100644 --- a/src/Command/Ssh/SshKeyCommandBase.php +++ b/src/Command/Ssh/SshKeyCommandBase.php @@ -71,8 +71,8 @@ protected function normalizePublicSshKey(string $publicKey): string protected function sshKeyIsAddedToKeychain(): bool { $process = $this->localMachineHelper->execute([ - 'ssh-add', - '-L', + 'ssh-add', + '-L', ], null, null, false); if ($process->isSuccessful()) { @@ -232,15 +232,15 @@ private function doCreateSshKey(string $filename, string $password): string $this->localMachineHelper->checkRequiredBinariesExist(['ssh-keygen']); $process = $this->localMachineHelper->execute([ - 'ssh-keygen', - '-t', - 'rsa', - '-b', - '4096', - '-f', - $filepath, - '-N', - $password, + 'ssh-keygen', + '-t', + 'rsa', + '-b', + '4096', + '-f', + $filepath, + '-N', + $password, ], null, null, false); if (!$process->isSuccessful()) { throw new AcquiaCliException($process->getOutput() . $process->getErrorOutput()); @@ -265,9 +265,9 @@ static function (mixed $value) { private function validateFilename(string $filename): string { $violations = Validation::createValidator()->validate($filename, [ - new Length(['min' => 5]), - new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), + new Length(['min' => 5]), + new NotBlank(), + new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -291,8 +291,8 @@ static function (mixed $value) { private function validatePassword(string $password): string { $violations = Validation::createValidator()->validate($password, [ - new Length(['min' => 5]), - new NotBlank(), + new Length(['min' => 5]), + new NotBlank(), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ssh/SshKeyInfoCommand.php b/src/Command/Ssh/SshKeyInfoCommand.php index 1c5a1f1a2..67bd204cf 100644 --- a/src/Command/Ssh/SshKeyInfoCommand.php +++ b/src/Command/Ssh/SshKeyInfoCommand.php @@ -67,10 +67,10 @@ private function determineSshKey(mixed $acquiaCloudClient): array $keys[$fingerprint]['fingerprint'] = $fingerprint; $keys[$fingerprint]['public_key'] = $key->public_key; $keys[$fingerprint]['cloud'] = [ - 'created_at' => $key->created_at, - 'fingerprint' => $key->fingerprint, - 'label' => $key->label, - 'uuid' => $key->uuid, + 'created_at' => $key->created_at, + 'fingerprint' => $key->fingerprint, + 'label' => $key->label, + 'uuid' => $key->uuid, ]; } foreach ($localKeys as $key) { @@ -78,7 +78,7 @@ private function determineSshKey(mixed $acquiaCloudClient): array $keys[$fingerprint]['fingerprint'] = $fingerprint; $keys[$fingerprint]['public_key'] = $key->getContents(); $keys[$fingerprint]['local'] = [ - 'filename' => $key->getFilename(), + 'filename' => $key->getFilename(), ]; } if ($fingerprint = $this->input->getOption('fingerprint')) { diff --git a/src/Command/Ssh/SshKeyListCommand.php b/src/Command/Ssh/SshKeyListCommand.php index 3f711a408..c70cf1001 100644 --- a/src/Command/Ssh/SshKeyListCommand.php +++ b/src/Command/Ssh/SshKeyListCommand.php @@ -29,9 +29,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (trim($localFile->getContents()) === trim($cloudKey->public_key)) { $hash = self::getFingerprint($cloudKey->public_key); $table->addRow([ - $cloudKey->label, - $localFile->getFilename(), - $hash, + $cloudKey->label, + $localFile->getFilename(), + $hash, ]); unset($cloudKeys[$index], $localKeys[$localIndex]); break; @@ -45,9 +45,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($cloudKeys as $cloudKey) { $hash = self::getFingerprint($cloudKey->public_key); $table->addRow([ - $cloudKey->label, - 'none', - $hash, + $cloudKey->label, + 'none', + $hash, ]); } $table->render(); @@ -57,9 +57,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($localKeys as $localFile) { $hash = self::getFingerprint($localFile->getContents()); $table->addRow([ - 'none', - $localFile->getFilename(), - $hash, + 'none', + $localFile->getFilename(), + $hash, ]); } $table->render(); diff --git a/src/Command/WizardCommandBase.php b/src/Command/WizardCommandBase.php index ccf773f16..2156da3a1 100644 --- a/src/Command/WizardCommandBase.php +++ b/src/Command/WizardCommandBase.php @@ -36,8 +36,8 @@ protected function initialize(InputInterface $input, OutputInterface $output): v protected function deleteLocalSshKey(): void { $this->localMachineHelper->getFilesystem()->remove([ - $this->publicSshKeyFilepath, - $this->privateSshKeyFilepath, + $this->publicSshKeyFilepath, + $this->privateSshKeyFilepath, ]); } diff --git a/src/Exception/AcquiaCliException.php b/src/Exception/AcquiaCliException.php index 28912e050..515d1d659 100644 --- a/src/Exception/AcquiaCliException.php +++ b/src/Exception/AcquiaCliException.php @@ -21,8 +21,8 @@ public function __construct( int $code = 0 ) { $eventProperties = [ - 'code' => $code, - 'message' => $rawMessage, + 'code' => $code, + 'message' => $rawMessage, ]; Amplitude::getInstance()->queueEvent('Threw exception', $eventProperties); diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index 5a48dcabd..696cbb433 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -137,8 +137,8 @@ private function executeProcess(Process $process, callable $callback = null, ?bo $process->wait($callback); $this->logger->notice('Command: {command} [Exit: {exit}]', [ - 'command' => $process->getCommandLine(), - 'exit' => $process->getExitCode(), + 'command' => $process->getCommandLine(), + 'exit' => $process->getExitCode(), ]); return $process; @@ -274,7 +274,7 @@ public static function getConfigDir(): string public static function getProjectDir(): ?string { $possibleProjectRoots = [ - getcwd(), + getcwd(), ]; // Check for PWD - some local environments will not have this key. if (getenv('PWD') && !in_array(getenv('PWD'), $possibleProjectRoots, true)) { diff --git a/src/Helpers/SshCommandTrait.php b/src/Helpers/SshCommandTrait.php index 98f7bbdbb..dd05f30f4 100644 --- a/src/Helpers/SshCommandTrait.php +++ b/src/Helpers/SshCommandTrait.php @@ -30,8 +30,8 @@ private function deleteSshKeyFromCloud(mixed $output, mixed $cloudKey = null): i $answer = $this->io->confirm("Do you also want to delete the corresponding local key files {$localFile->getRealPath()} and $privateKeyPath ?", false); if ($answer) { $this->localMachineHelper->getFilesystem()->remove([ - $localFile->getRealPath(), - $privateKeyPath, + $localFile->getRealPath(), + $privateKeyPath, ]); $this->io->success("Deleted $publicKeyPath and $privateKeyPath"); return 0; diff --git a/src/Helpers/SshHelper.php b/src/Helpers/SshHelper.php index a62582448..e1471e597 100644 --- a/src/Helpers/SshHelper.php +++ b/src/Helpers/SshHelper.php @@ -40,9 +40,9 @@ public function executeCommand(string $sshUrl, array $commandArgs, bool $printOu $process = $this->sendCommand($sshUrl, $commandArgs, $printOutput, $timeout); $this->logger->debug('Command: {command} [Exit: {exit}]', [ - 'command' => $commandSummary, - 'env' => $sshUrl, - 'exit' => $process->getExitCode(), + 'command' => $commandSummary, + 'env' => $sshUrl, + 'exit' => $process->getExitCode(), ]); if (!$process->isSuccessful() && $process->getExitCode() === 255) { @@ -107,12 +107,12 @@ private function getCommandSummary(array $commandArgs): string private function getConnectionArgs(string $url): array { return [ - 'ssh', - $url, - '-t', - '-o StrictHostKeyChecking=no', - '-o AddressFamily inet', - '-o LogLevel=ERROR', + 'ssh', + $url, + '-t', + '-o StrictHostKeyChecking=no', + '-o AddressFamily inet', + '-o LogLevel=ERROR', ]; } diff --git a/src/Helpers/TelemetryHelper.php b/src/Helpers/TelemetryHelper.php index aef7016e2..aab4aa901 100644 --- a/src/Helpers/TelemetryHelper.php +++ b/src/Helpers/TelemetryHelper.php @@ -63,7 +63,7 @@ public function initializeBugsnag(): void $userId = $this->getUserId(); if (isset($userId)) { $report->setUser([ - 'id' => $userId, + 'id' => $userId, ]); } $context = $report->getContext(); @@ -143,14 +143,14 @@ public static function normalizeAhEnv(string $ah_env): string private function getTelemetryUserData(): array { $data = [ - 'ah_app_uuid' => getenv('AH_APPLICATION_UUID'), - 'ah_env' => $this->normalizeAhEnv(AcquiaDrupalEnvironmentDetector::getAhEnv()), - 'ah_group' => AcquiaDrupalEnvironmentDetector::getAhGroup(), - 'ah_non_production' => getenv('AH_NON_PRODUCTION'), - 'ah_realm' => getenv('AH_REALM'), - 'CI' => getenv('CI'), - 'env_provider' => $this->getEnvironmentProvider(), - 'php_version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, + 'ah_app_uuid' => getenv('AH_APPLICATION_UUID'), + 'ah_env' => $this->normalizeAhEnv(AcquiaDrupalEnvironmentDetector::getAhEnv()), + 'ah_group' => AcquiaDrupalEnvironmentDetector::getAhGroup(), + 'ah_non_production' => getenv('AH_NON_PRODUCTION'), + 'ah_realm' => getenv('AH_REALM'), + 'CI' => getenv('CI'), + 'env_provider' => $this->getEnvironmentProvider(), + 'php_version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, ]; try { $user = $this->getUserData(); @@ -224,8 +224,8 @@ private function getDefaultUserData(): array // @todo Cache this! $account = new Account($this->cloudApiClientService->getClient()); return [ - 'is_acquian' => str_ends_with($account->get()->mail, 'acquia.com'), - 'uuid' => $account->get()->uuid, + 'is_acquian' => str_ends_with($account->get()->mail, 'acquia.com'), + 'uuid' => $account->get()->uuid, ]; } @@ -241,28 +241,28 @@ public static function getProviders(): array // Define the environment variables associated with each provider. // phpcs:ignore SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder return [ - 'lando' => ['LANDO'], - 'ddev' => ['IS_DDEV_PROJECT'], + 'lando' => ['LANDO'], + 'ddev' => ['IS_DDEV_PROJECT'], // Check Lando and DDEV first because the hijack AH_SITE_ENVIRONMENT. - 'acquia' => ['AH_SITE_ENVIRONMENT'], - 'bamboo' => ['BAMBOO_BUILDNUMBER'], - 'beanstalk' => ['BEANSTALK_ENVIRONMENT'], - 'bitbucket' => ['BITBUCKET_BUILD_NUMBER'], - 'bitrise' => ['BITRISE_IO'], - 'buddy' => ['BUDDY_WORKSPACE_ID'], - 'circleci' => ['CIRCLECI'], - 'codebuild' => ['CODEBUILD_BUILD_ID'], - 'docksal' => ['DOCKSAL_VERSION'], - 'drone' => ['DRONE'], - 'github' => ['GITHUB_ACTIONS'], - 'gitlab' => ['GITLAB_CI'], - 'heroku' => ['HEROKU_TEST_RUN_ID'], - 'jenkins' => ['JENKINS_URL'], - 'pantheon' => ['PANTHEON_ENVIRONMENT'], - 'pipelines' => ['PIPELINE_ENV'], - 'platformsh' => ['PLATFORM_ENVIRONMENT'], - 'teamcity' => ['TEAMCITY_VERSION'], - 'travis' => ['TRAVIS'], + 'acquia' => ['AH_SITE_ENVIRONMENT'], + 'bamboo' => ['BAMBOO_BUILDNUMBER'], + 'beanstalk' => ['BEANSTALK_ENVIRONMENT'], + 'bitbucket' => ['BITBUCKET_BUILD_NUMBER'], + 'bitrise' => ['BITRISE_IO'], + 'buddy' => ['BUDDY_WORKSPACE_ID'], + 'circleci' => ['CIRCLECI'], + 'codebuild' => ['CODEBUILD_BUILD_ID'], + 'docksal' => ['DOCKSAL_VERSION'], + 'drone' => ['DRONE'], + 'github' => ['GITHUB_ACTIONS'], + 'gitlab' => ['GITLAB_CI'], + 'heroku' => ['HEROKU_TEST_RUN_ID'], + 'jenkins' => ['JENKINS_URL'], + 'pantheon' => ['PANTHEON_ENVIRONMENT'], + 'pipelines' => ['PIPELINE_ENV'], + 'platformsh' => ['PLATFORM_ENVIRONMENT'], + 'teamcity' => ['TEAMCITY_VERSION'], + 'travis' => ['TRAVIS'], ]; } } diff --git a/src/Kernel.php b/src/Kernel.php index 77970db95..053bfa68b 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -52,7 +52,7 @@ protected function registerExtensionConfiguration(mixed $loader): void $finder = new Finder(); $extensions = $finder->files() ->in([ - __DIR__ . '/../../', + __DIR__ . '/../../', ]) ->depth(1) ->name('acli.services.yml'); @@ -70,8 +70,8 @@ protected function getContainerLoader(ContainerInterface $container): Delegating { $locator = new FileLocator([$this->getProjectDir()]); $resolver = new LoaderResolver([ - new YamlFileLoader($container, $locator), - new DirectoryLoader($container, $locator), + new YamlFileLoader($container, $locator), + new DirectoryLoader($container, $locator), ]); return new DelegatingLoader($resolver); @@ -98,11 +98,11 @@ public function process(ContainerBuilder $containerBuilder): void if ($definition->hasTag('kernel.event_listener')) { foreach ($definition->getTag('kernel.event_listener') as $tag) { $dispatcherDefinition->addMethodCall('addListener', [ - $tag['event'], - [ - new ServiceClosureArgument(new Reference($definition->getClass())), - $tag['method'], - ], + $tag['event'], + [ + new ServiceClosureArgument(new Reference($definition->getClass())), + $tag['method'], + ], ]); } } @@ -118,12 +118,12 @@ public function process(ContainerBuilder $containerBuilder): void } $appDefinition->addMethodCall('add', [ - new Reference($definition->getClass()), + new Reference($definition->getClass()), ]); } $appDefinition->addMethodCall('setDispatcher', [ - $dispatcherDefinition, + $dispatcherDefinition, ]); } }; diff --git a/src/Output/Spinner/Spinner.php b/src/Output/Spinner/Spinner.php index b3ab9ccb6..1817ae244 100644 --- a/src/Output/Spinner/Spinner.php +++ b/src/Output/Spinner/Spinner.php @@ -15,66 +15,66 @@ class Spinner { private const CHARS = ['⠏', '⠛', '⠹', '⢸', '⣰', '⣤', '⣆', '⡇']; private const COLORS = [ - 196, - 196, - 202, - 202, - 208, - 208, - 214, - 214, - 220, - 220, - 226, - 226, - 190, - 190, - 154, - 154, - 118, - 118, - 82, - 82, - 46, - 46, - 47, - 47, - 48, - 48, - 49, - 49, - 50, - 50, - 51, - 51, - 45, - 45, - 39, - 39, - 33, - 33, - 27, - 27, - 56, - 56, - 57, - 57, - 93, - 93, - 129, - 129, - 165, - 165, - 201, - 201, - 200, - 200, - 199, - 199, - 198, - 198, - 197, - 197, + 196, + 196, + 202, + 202, + 208, + 208, + 214, + 214, + 220, + 220, + 226, + 226, + 190, + 190, + 154, + 154, + 118, + 118, + 82, + 82, + 46, + 46, + 47, + 47, + 48, + 48, + 49, + 49, + 50, + 50, + 51, + 51, + 45, + 45, + 39, + 39, + 33, + 33, + 27, + 27, + 56, + 56, + 57, + 57, + 93, + 93, + 129, + 129, + 165, + 165, + 201, + 201, + 200, + 200, + 199, + 199, + 198, + 198, + 197, + 197, ]; private int $currentCharIdx = 0; diff --git a/tests/phpunit/src/AcsfApi/AcsfServiceTest.php b/tests/phpunit/src/AcsfApi/AcsfServiceTest.php index 4e381ef6b..1640c8b3a 100644 --- a/tests/phpunit/src/AcsfApi/AcsfServiceTest.php +++ b/tests/phpunit/src/AcsfApi/AcsfServiceTest.php @@ -24,22 +24,22 @@ protected function setUp(): void public function providerTestIsMachineAuthenticated(): array { return [ - [ - ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => 'secret'], - true, - ], - [ - ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => 'secret'], - true, - ], - [ - ['ACSF_USERNAME' => null, 'ACSF_KEY' => null], - false, - ], - [ - ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => null], - false, - ], + [ + ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => 'secret'], + true, + ], + [ + ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => 'secret'], + true, + ], + [ + ['ACSF_USERNAME' => null, 'ACSF_KEY' => null], + false, + ], + [ + ['ACSF_USERNAME' => 'key', 'ACSF_KEY' => null], + false, + ], ]; } diff --git a/tests/phpunit/src/Application/ComposerScriptsListenerTest.php b/tests/phpunit/src/Application/ComposerScriptsListenerTest.php index 22acc722a..b2565157e 100644 --- a/tests/phpunit/src/Application/ComposerScriptsListenerTest.php +++ b/tests/phpunit/src/Application/ComposerScriptsListenerTest.php @@ -25,11 +25,11 @@ class ComposerScriptsListenerTest extends ApplicationTestBase public function testPreScripts(): void { $json = [ - 'scripts' => [ - 'pre-acli-hello-world' => [ - 'echo "good morning world"', - ], - ], + 'scripts' => [ + 'pre-acli-hello-world' => [ + 'echo "good morning world"', + ], + ], ]; file_put_contents( Path::join($this->projectDir, 'composer.json'), @@ -37,7 +37,7 @@ public function testPreScripts(): void ); $this->mockRequest('getAccount'); $this->setInput([ - 'command' => 'hello-world', + 'command' => 'hello-world', ]); $buffer = $this->runApp(); self::assertStringContainsString('pre-acli-hello-world', $buffer); @@ -49,11 +49,11 @@ public function testPreScripts(): void public function testPostScripts(): void { $json = [ - 'scripts' => [ - 'post-acli-hello-world' => [ - 'echo "goodbye world"', - ], - ], + 'scripts' => [ + 'post-acli-hello-world' => [ + 'echo "goodbye world"', + ], + ], ]; file_put_contents( Path::join($this->projectDir, 'composer.json'), @@ -61,7 +61,7 @@ public function testPostScripts(): void ); $this->mockRequest('getAccount'); $this->setInput([ - 'command' => 'hello-world', + 'command' => 'hello-world', ]); $buffer = $this->runApp(); self::assertStringContainsString('post-acli-hello-world', $buffer); @@ -70,19 +70,19 @@ public function testPostScripts(): void public function testNoScripts(): void { $json = [ - 'scripts' => [ - 'pre-acli-pull-code' => [ - 'echo "goodbye world"', - ], - ], + 'scripts' => [ + 'pre-acli-pull-code' => [ + 'echo "goodbye world"', + ], + ], ]; file_put_contents( Path::join($this->projectDir, 'composer.json'), json_encode($json, JSON_THROW_ON_ERROR) ); $this->setInput([ - '--no-scripts' => true, - 'command' => 'pull:code', + '--no-scripts' => true, + 'command' => 'pull:code', ]); $buffer = $this->runApp(); self::assertStringNotContainsString('pre-acli-pull-code', $buffer); diff --git a/tests/phpunit/src/Application/ExceptionApplicationTest.php b/tests/phpunit/src/Application/ExceptionApplicationTest.php index 69300a58a..a37f9e674 100644 --- a/tests/phpunit/src/Application/ExceptionApplicationTest.php +++ b/tests/phpunit/src/Application/ExceptionApplicationTest.php @@ -23,8 +23,8 @@ class ExceptionApplicationTest extends ApplicationTestBase public function testInvalidApiCredentials(): void { $this->setInput([ - 'applicationUuid' => '2ed281d4-9dec-4cc3-ac63-691c3ba002c2', - 'command' => 'aliases', + 'applicationUuid' => '2ed281d4-9dec-4cc3-ac63-691c3ba002c2', + 'command' => 'aliases', ]); $this->mockUnauthorizedRequest(); $buffer = $this->runApp(); diff --git a/tests/phpunit/src/Application/HelpApplicationTest.php b/tests/phpunit/src/Application/HelpApplicationTest.php index f40dec53f..cdbab643f 100644 --- a/tests/phpunit/src/Application/HelpApplicationTest.php +++ b/tests/phpunit/src/Application/HelpApplicationTest.php @@ -21,8 +21,8 @@ class HelpApplicationTest extends ApplicationTestBase public function testApplicationAliasHelp(): void { $this->setInput([ - 'command' => 'help', - 'command_name' => 'app:link', + 'command' => 'help', + 'command_name' => 'app:link', ]); $buffer = $this->runApp(); $this->assertStringContainsString('The Cloud Platform application UUID or alias (i.e. an application name optionally prefixed with the realm)', $buffer); @@ -41,8 +41,8 @@ public function testApplicationAliasHelp(): void public function testEnvironmentAliasHelp(): void { $this->setInput([ - 'command' => 'help', - 'command_name' => 'log:tail', + 'command' => 'help', + 'command_name' => 'log:tail', ]); $buffer = $this->runApp(); $this->assertStringContainsString('The Cloud Platform environment ID or alias (i.e. an application and environment name optionally prefixed with the realm)', $buffer); diff --git a/tests/phpunit/src/Application/KernelTest.php b/tests/phpunit/src/Application/KernelTest.php index 3963f24f5..0faec8699 100644 --- a/tests/phpunit/src/Application/KernelTest.php +++ b/tests/phpunit/src/Application/KernelTest.php @@ -14,7 +14,7 @@ class KernelTest extends ApplicationTestBase public function testRun(): void { $this->setInput([ - 'command' => 'list', + 'command' => 'list', ]); $buffer = $this->runApp(); // A bit dumb that we need to break these up, but the available commands vary based on whether a browser is available or the session is interactive. diff --git a/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php b/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php index 560e9c7e4..866f07ea8 100644 --- a/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php +++ b/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php @@ -55,10 +55,10 @@ public function testAccessToken(): void self::assertEquals(self::$accessToken, $this->cloudCredentials->getCloudAccessToken()); $connectorFactory = new ConnectorFactory( [ - 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), - 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), - 'key' => null, - 'secret' => null, + 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), + 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), + 'key' => null, + 'secret' => null, ] ); $connector = $connectorFactory->createConnector(); @@ -83,8 +83,8 @@ public function testTokenFile(): void { $accessTokenExpiry = time() + 300; $directory = [ - 'expiry' => (string) $accessTokenExpiry . "\n", - 'token' => self::$accessToken . "\n", + 'expiry' => (string) $accessTokenExpiry . "\n", + 'token' => self::$accessToken . "\n", ]; $vfs = vfsStream::setup('root', null, $directory); $tokenFile = Path::join($vfs->url(), 'token'); @@ -99,7 +99,7 @@ public function testMissingTokenFile(): void { $accessTokenExpiry = time() + 300; $directory = [ - 'expiry' => (string) $accessTokenExpiry, + 'expiry' => (string) $accessTokenExpiry, ]; $vfs = vfsStream::setup('root', null, $directory); $tokenFile = Path::join($vfs->url(), 'token'); @@ -114,7 +114,7 @@ public function testMissingTokenFile(): void public function testMissingExpiryFile(): void { $directory = [ - 'token' => self::$accessToken, + 'token' => self::$accessToken, ]; $vfs = vfsStream::setup('root', null, $directory); $tokenFile = Path::join($vfs->url(), 'token'); @@ -137,10 +137,10 @@ public function testConnector(): void self::assertEquals(self::$accessToken, $this->cloudCredentials->getCloudAccessToken()); $connectorFactory = new ConnectorFactory( [ - 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), - 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), - 'key' => $this->cloudCredentials->getCloudKey(), - 'secret' => $this->cloudCredentials->getCloudSecret(), + 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), + 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), + 'key' => $this->cloudCredentials->getCloudKey(), + 'secret' => $this->cloudCredentials->getCloudSecret(), ] ); $connector = $connectorFactory->createConnector(); @@ -152,10 +152,10 @@ public function testExpiredAccessToken(): void self::setAccessTokenEnvVars(true); $connectorFactory = new ConnectorFactory( [ - 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), - 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), - 'key' => null, - 'secret' => null, + 'accessToken' => $this->cloudCredentials->getCloudAccessToken(), + 'accessTokenExpiry' => $this->cloudCredentials->getCloudAccessTokenExpiry(), + 'key' => null, + 'secret' => null, ] ); $connector = $connectorFactory->createConnector(); @@ -167,9 +167,9 @@ public function testConnectorConfig(): void self::setAccessTokenEnvVars(); $connectorFactory = new ConnectorFactory( [ - 'accessToken' => null, - 'key' => $this->cloudCredentials->getCloudKey(), - 'secret' => $this->cloudCredentials->getCloudSecret(), + 'accessToken' => null, + 'key' => $this->cloudCredentials->getCloudKey(), + 'secret' => $this->cloudCredentials->getCloudSecret(), ] ); $clientService = new ClientService($connectorFactory, $this->application, $this->cloudCredentials); @@ -186,9 +186,9 @@ public function testIdeHeader(): void IdeHelper::setCloudIdeEnvVars(); $connectorFactory = new ConnectorFactory( [ - 'accessToken' => null, - 'key' => $this->cloudCredentials->getCloudKey(), - 'secret' => $this->cloudCredentials->getCloudSecret(), + 'accessToken' => null, + 'key' => $this->cloudCredentials->getCloudKey(), + 'secret' => $this->cloudCredentials->getCloudSecret(), ] ); $clientService = new ClientService($connectorFactory, $this->application, $this->cloudCredentials); diff --git a/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php b/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php index b66b814da..087cb3e91 100644 --- a/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php +++ b/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php @@ -23,14 +23,14 @@ class AcsfClientServiceTest extends TestBase public function providerTestIsMachineAuthenticated(): array { return [ - [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], - false, - ], - [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], - false, - ], + [ + ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], + false, + ], + [ + ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], + false, + ], ]; } diff --git a/tests/phpunit/src/CloudApi/ClientServiceTest.php b/tests/phpunit/src/CloudApi/ClientServiceTest.php index 4ecac1dfa..fbf31875a 100644 --- a/tests/phpunit/src/CloudApi/ClientServiceTest.php +++ b/tests/phpunit/src/CloudApi/ClientServiceTest.php @@ -18,22 +18,22 @@ class ClientServiceTest extends TestBase public function providerTestIsMachineAuthenticated(): array { return [ - [ - ['ACLI_ACCESS_TOKEN' => 'token', 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], - true, - ], - [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], - true, - ], - [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], - false, - ], - [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], - false, - ], + [ + ['ACLI_ACCESS_TOKEN' => 'token', 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], + true, + ], + [ + ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], + true, + ], + [ + ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], + false, + ], + [ + ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], + false, + ], ]; } diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index 1a7a36ea5..15a7a868e 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -212,13 +212,13 @@ protected static function inputChooseEnvironment(): array { return [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, ]; } @@ -557,18 +557,18 @@ protected function getApiCommandByName(string $name): ApiBaseCommand|null protected function getMockedGitLabProject(mixed $projectId): array { return [ - 'default_branch' => 'master', - 'description' => '', - 'http_url_to_repo' => 'https://code.cloudservices.acquia.io/matthew.grasmick/codestudiodemo.git', - 'id' => $projectId, - 'name' => 'codestudiodemo', - 'name_with_namespace' => 'Matthew Grasmick / codestudiodemo', - 'path' => 'codestudiodemo', - 'path_with_namespace' => 'matthew.grasmick/codestudiodemo', - 'topics' => [ - 0 => 'Acquia Cloud Application', - ], - 'web_url' => 'https://code.cloudservices.acquia.io/matthew.grasmick/codestudiodemo', + 'default_branch' => 'master', + 'description' => '', + 'http_url_to_repo' => 'https://code.cloudservices.acquia.io/matthew.grasmick/codestudiodemo.git', + 'id' => $projectId, + 'name' => 'codestudiodemo', + 'name_with_namespace' => 'Matthew Grasmick / codestudiodemo', + 'path' => 'codestudiodemo', + 'path_with_namespace' => 'matthew.grasmick/codestudiodemo', + 'topics' => [ + 0 => 'Acquia Cloud Application', + ], + 'web_url' => 'https://code.cloudservices.acquia.io/matthew.grasmick/codestudiodemo', ]; } @@ -589,11 +589,11 @@ protected function mockGitlabGetToken(mixed $localMachineHelper, string $gitlabT $process = $this->mockProcess($success); $process->getOutput()->willReturn($gitlabToken); $localMachineHelper->execute([ - 'glab', - 'config', - 'get', - 'token', - '--host=' . $gitlabHost, + 'glab', + 'config', + 'get', + 'token', + '--host=' . $gitlabHost, ], null, null, false)->willReturn($process->reveal()); } @@ -602,10 +602,10 @@ protected function mockGitlabGetHost(mixed $localMachineHelper, string $gitlabHo $process = $this->mockProcess(); $process->getOutput()->willReturn($gitlabHost); $localMachineHelper->execute([ - 'glab', - 'config', - 'get', - 'host', + 'glab', + 'config', + 'get', + 'host', ], null, null, false)->willReturn($process->reveal()); } @@ -613,45 +613,45 @@ protected function mockGitLabUsersMe(ObjectProphecy|\Gitlab\Client $gitlabClient { $users = $this->prophet->prophesize(Users::class); $me = [ - 'avatar_url' => 'https://secure.gravatar.com/avatar/5ee7b8ad954bf7156e6eb57a45d60dec?s=80&d=identicon', - 'bio' => '', - 'bot' => false, - 'can_create_group' => true, - 'can_create_project' => true, - 'color_scheme_id' => 1, - 'commit_email' => 'matthew.grasmick@acquia.com', - 'confirmed_at' => '2021-12-21T02:26:51.898Z', - 'created_at' => '2021-12-21T02:26:52.240Z', - 'current_sign_in_at' => '2022-01-22T01:40:55.418Z', - 'email' => 'matthew.grasmick@acquia.com', - 'external' => false, - 'followers' => 0, - 'following' => 0, - 'id' => 20, - 'identities' => [], - 'is_admin' => true, - 'job_title' => '', - 'last_activity_on' => '2022-01-22', - 'last_sign_in_at' => '2022-01-21T23:00:49.035Z', - 'linkedin' => '', - 'local_time' => '2:00 AM', - 'location' => null, - 'name' => 'Matthew Grasmick', - 'note' => '', - 'organization' => null, - 'private_profile' => false, - 'projects_limit' => 100000, - 'pronouns' => null, - 'public_email' => '', - 'skype' => '', - 'state' => 'active', - 'theme_id' => 1, - 'twitter' => '', - 'two_factor_enabled' => false, - 'username' => 'matthew.grasmick', - 'website_url' => '', - 'web_url' => 'https://code.dev.cloudservices.acquia.io/matthew.grasmick', - 'work_information' => null, + 'avatar_url' => 'https://secure.gravatar.com/avatar/5ee7b8ad954bf7156e6eb57a45d60dec?s=80&d=identicon', + 'bio' => '', + 'bot' => false, + 'can_create_group' => true, + 'can_create_project' => true, + 'color_scheme_id' => 1, + 'commit_email' => 'matthew.grasmick@acquia.com', + 'confirmed_at' => '2021-12-21T02:26:51.898Z', + 'created_at' => '2021-12-21T02:26:52.240Z', + 'current_sign_in_at' => '2022-01-22T01:40:55.418Z', + 'email' => 'matthew.grasmick@acquia.com', + 'external' => false, + 'followers' => 0, + 'following' => 0, + 'id' => 20, + 'identities' => [], + 'is_admin' => true, + 'job_title' => '', + 'last_activity_on' => '2022-01-22', + 'last_sign_in_at' => '2022-01-21T23:00:49.035Z', + 'linkedin' => '', + 'local_time' => '2:00 AM', + 'location' => null, + 'name' => 'Matthew Grasmick', + 'note' => '', + 'organization' => null, + 'private_profile' => false, + 'projects_limit' => 100000, + 'pronouns' => null, + 'public_email' => '', + 'skype' => '', + 'state' => 'active', + 'theme_id' => 1, + 'twitter' => '', + 'two_factor_enabled' => false, + 'username' => 'matthew.grasmick', + 'website_url' => '', + 'web_url' => 'https://code.dev.cloudservices.acquia.io/matthew.grasmick', + 'work_information' => null, ]; $users->me()->willReturn($me); $gitlabClient->users()->willReturn($users->reveal()); @@ -690,29 +690,29 @@ protected function mockGetGitLabProjects(mixed $applicationUuid, mixed $gitlabPr protected function getMockGitLabVariables(): array { return [ - 0 => [ - 'environment_scope' => '*', - 'key' => 'ACQUIA_APPLICATION_UUID', - 'masked' => true, - 'protected' => false, - 'value' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', - 'variable_type' => 'env_var', - ], - 1 => [ - 'environment_scope' => '*', - 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', - 'masked' => true, - 'protected' => false, - 'value' => '17feaf34-5d04-402b-9a67-15d5161d24e1', - 'variable_type' => 'env_var', - ], - 2 => [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', - 'masked' => false, - 'protected' => false, - 'value' => 'X1u\/PIQXtYaoeui.4RJSJpGZjwmWYmfl5AUQkAebYE=', - 'variable_type' => 'env_var', - ], + 0 => [ + 'environment_scope' => '*', + 'key' => 'ACQUIA_APPLICATION_UUID', + 'masked' => true, + 'protected' => false, + 'value' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'variable_type' => 'env_var', + ], + 1 => [ + 'environment_scope' => '*', + 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', + 'masked' => true, + 'protected' => false, + 'value' => '17feaf34-5d04-402b-9a67-15d5161d24e1', + 'variable_type' => 'env_var', + ], + 2 => [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', + 'masked' => false, + 'protected' => false, + 'value' => 'X1u\/PIQXtYaoeui.4RJSJpGZjwmWYmfl5AUQkAebYE=', + 'variable_type' => 'env_var', + ], ]; } @@ -726,8 +726,8 @@ final public static function assertStringContainsStringIgnoringLineEndings(strin $haystack = strtr( $haystack, [ - "\r" => "\n", - "\r\n" => "\n", + "\r" => "\n", + "\r\n" => "\n", ] ); static::assertThat($haystack, new StringContains($needle, false), $message); diff --git a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php index 428ed6b02..6790e484e 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php @@ -42,10 +42,10 @@ public function testAcsfCommandExecutionForHttpPostWithMultipleDataTypes(): void $this->clientProphecy->addOption('json', ["uids" => ["1", "2", "3"]])->shouldBeCalled(); $this->command = $this->getApiCommandByName('acsf:groups:add-members'); $this->executeCommand([ - 'uids' => '1,2,3', + 'uids' => '1,2,3', ], [ // group_id. - '1', + '1', ]); // Assert. @@ -60,7 +60,7 @@ public function testAcsfCommandExecutionBool(): void $this->command = $this->getApiCommandByName('acsf:updates:pause'); $this->executeCommand([], [ // Pause. - '1', + '1', ]); // Assert. @@ -90,12 +90,12 @@ public function testAcsfCommandExecutionForHttpGet(): void public function providerTestAcsfCommandExecutionForHttpGetMultiple(): array { return [ - ['get', '/api/v1/audit', '/api/v1/audit', 'acsf:info:audit-events-find', [], []], - ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91,81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], - ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91','81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], - ['post', '/api/v1/sites/{site_id}/backup', '/api/v1/sites/1/backup', 'acsf:sites:backup', ['--label' => 'foo', 'site_id' => '1'], ['label' => 'foo']], - ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1'], ['group_id' => 'foo', 'uids' => 1]], - ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1,3'], ['group_id' => 'foo', 'uids' => [1, 3]]], + ['get', '/api/v1/audit', '/api/v1/audit', 'acsf:info:audit-events-find', [], []], + ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91,81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], + ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91','81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], + ['post', '/api/v1/sites/{site_id}/backup', '/api/v1/sites/1/backup', 'acsf:sites:backup', ['--label' => 'foo', 'site_id' => '1'], ['label' => 'foo']], + ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1'], ['group_id' => 'foo', 'uids' => 1]], + ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1,3'], ['group_id' => 'foo', 'uids' => [1, 3]]], ]; } @@ -126,7 +126,7 @@ public function testAcsfUnauthenticatedFailure(): void $inputs = [ // Would you like to share anonymous performance usage and data? - 'n', + 'n', ]; $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('This machine is not yet authenticated with Site Factory.'); diff --git a/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php index bab52a8ac..b5e777d50 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php @@ -28,63 +28,63 @@ public function providerTestAuthLoginCommand(): array { return [ // Data set 0. - [ + [ // $machineIsAuthenticated - false, + false, // $inputs - [ + [ // Would you like to share anonymous performance usage and data? (yes/no) [yes]. - 'yes', + 'yes', // Enter the full URL of the factory. - $this->acsfCurrentFactoryUrl, + $this->acsfCurrentFactoryUrl, // Enter a value for username. - $this->acsfUsername, + $this->acsfUsername, // Enter a value for key. - $this->acsfKey, - ], - // No arguments, all interactive. - [], - // Output to assert. - 'Saved credentials', - ], - // Data set 1. - [ - // $machineIsAuthenticated - false, - // $inputs - [], - // Arguments. - [ - // Enter the full URL of the factory. - '--factory-url' => $this->acsfCurrentFactoryUrl, - // Enter a value for key. - '--key' => $this->acsfKey, - // Enter a value for username. - '--username' => $this->acsfUsername, - ], - // Output to assert. - 'Saved credentials', - // $config. - $this->getAcsfCredentialsFileContents(), - ], - // Data set 2. - [ - // $machineIsAuthenticated - true, - // $inputs - [ - // Choose a factory to log in to. - $this->acsfCurrentFactoryUrl, - // Choose which user to log in as. - $this->acsfUsername, - ], - // Arguments. - [], - // Output to assert. - "Acquia CLI is now logged in to $this->acsfCurrentFactoryUrl as $this->acsfUsername", - // $config. - $this->getAcsfCredentialsFileContents(), - ], + $this->acsfKey, + ], + // No arguments, all interactive. + [], + // Output to assert. + 'Saved credentials', + ], + // Data set 1. + [ + // $machineIsAuthenticated + false, + // $inputs + [], + // Arguments. + [ + // Enter the full URL of the factory. + '--factory-url' => $this->acsfCurrentFactoryUrl, + // Enter a value for key. + '--key' => $this->acsfKey, + // Enter a value for username. + '--username' => $this->acsfUsername, + ], + // Output to assert. + 'Saved credentials', + // $config. + $this->getAcsfCredentialsFileContents(), + ], + // Data set 2. + [ + // $machineIsAuthenticated + true, + // $inputs + [ + // Choose a factory to log in to. + $this->acsfCurrentFactoryUrl, + // Choose which user to log in as. + $this->acsfUsername, + ], + // Arguments. + [], + // Output to assert. + "Acquia CLI is now logged in to $this->acsfCurrentFactoryUrl as $this->acsfUsername", + // $config. + $this->getAcsfCredentialsFileContents(), + ], ]; } diff --git a/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php index ca790931a..560b6c18f 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php @@ -28,24 +28,24 @@ public function providerTestAuthLogoutCommand(): array { return [ // Data set 0. - [ + [ // $machineIsAuthenticated - false, + false, // $inputs - [], - ], - // Data set 1. - [ - // $machineIsAuthenticated - true, - // $inputs - [ - // Choose a Factory to logout of. - 0, - ], - // $config. - $this->getAcsfCredentialsFileContents(), - ], + [], + ], + // Data set 1. + [ + // $machineIsAuthenticated + true, + // $inputs + [ + // Choose a Factory to logout of. + 0, + ], + // $config. + $this->getAcsfCredentialsFileContents(), + ], ]; } diff --git a/tests/phpunit/src/Commands/Acsf/AcsfCommandTestBase.php b/tests/phpunit/src/Commands/Acsf/AcsfCommandTestBase.php index 826d227c4..98dd15d10 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfCommandTestBase.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfCommandTestBase.php @@ -31,20 +31,20 @@ abstract class AcsfCommandTestBase extends CommandTestBase protected function getAcsfCredentialsFileContents(): array { return [ - 'acsf_active_factory' => $this->acsfCurrentFactoryUrl, - 'acsf_factories' => [ - $this->acsfCurrentFactoryUrl => [ - 'active_user' => $this->acsfActiveUser, - 'url' => $this->acsfCurrentFactoryUrl, - 'users' => [ - $this->acsfUsername => [ - 'key' => $this->acsfKey, - 'username' => $this->acsfUsername, - ], - ], - ], - ], - DataStoreContract::SEND_TELEMETRY => false, + 'acsf_active_factory' => $this->acsfCurrentFactoryUrl, + 'acsf_factories' => [ + $this->acsfCurrentFactoryUrl => [ + 'active_user' => $this->acsfActiveUser, + 'url' => $this->acsfCurrentFactoryUrl, + 'users' => [ + $this->acsfUsername => [ + 'key' => $this->acsfKey, + 'username' => $this->acsfUsername, + ], + ], + ], + ], + DataStoreContract::SEND_TELEMETRY => false, ]; } } diff --git a/tests/phpunit/src/Commands/Api/ApiCommandTest.php b/tests/phpunit/src/Commands/Api/ApiCommandTest.php index 7bf45b3bf..557e2ff01 100644 --- a/tests/phpunit/src/Commands/Api/ApiCommandTest.php +++ b/tests/phpunit/src/Commands/Api/ApiCommandTest.php @@ -37,8 +37,8 @@ public function testArgumentsInteraction(): void { $this->command = $this->getApiCommandByName('api:environments:log-download'); $this->executeCommand([], [ - '289576-53785bca-1946-4adc-a022-e50d24686c20', - 'apache-access', + '289576-53785bca-1946-4adc-a022-e50d24686c20', + 'apache-access', ]); $output = $this->getDisplay(); $this->assertStringContainsString('Enter a value for environmentId', $output); @@ -53,9 +53,9 @@ public function testArgumentsInteractionValidation(): void $this->command = $this->getApiCommandByName('api:environments:variable-update'); try { $this->executeCommand([], [ - '289576-53785bca-1946-4adc-a022-e50d24686c20', - 'AH_SOMETHING', - 'AH_SOMETHING', + '289576-53785bca-1946-4adc-a022-e50d24686c20', + 'AH_SOMETHING', + 'AH_SOMETHING', ]); } catch (MissingInputException) { } @@ -68,7 +68,7 @@ public function testArgumentsInteractionValidationFormat(): void $this->command = $this->getApiCommandByName('api:notifications:find'); try { $this->executeCommand([], [ - 'test', + 'test', ]); } catch (MissingInputException) { } @@ -93,11 +93,11 @@ public function testApiCommandErrorResponse(): void $this->executeCommand(['applicationUuid' => $invalidUuid], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - '0', + '0', // Would you like to link the Cloud application Sample application to this repository? - 'n', + 'n', ]); // Assert. @@ -135,8 +135,8 @@ public function testObjectParam(): void $this->mockRequest('putEnvironmentCloudActions', '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->command = $this->getApiCommandByName('api:environments:cloud-actions-update'); $this->executeCommand([ - 'cloud-actions' => '{"fb4aa87a-8be2-42c6-bdf0-ef9d09a3de70":true}', - 'environmentId' => '24-a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'cloud-actions' => '{"fb4aa87a-8be2-42c6-bdf0-ef9d09a3de70":true}', + 'environmentId' => '24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ]); $output = $this->getDisplay(); $this->assertStringContainsString('Cloud Actions have been updated.', $output); @@ -150,11 +150,11 @@ public function testInferApplicationUuidArgument(): void $this->command = $this->getApiCommandByName('api:applications:find'); $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - '0', + '0', // Would you like to link the Cloud application Sample application to this repository? - 'n', + 'n', ]); // Assert. @@ -170,8 +170,8 @@ public function testInferApplicationUuidArgument(): void public function providerTestConvertApplicationAliasToUuidArgument(): array { return [ - [false], - [true], + [false], + [true], ]; } @@ -202,11 +202,11 @@ public function testConvertApplicationAliasToUuidArgument(bool $support): void $this->executeCommand(['applicationUuid' => $alias], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the Cloud application Sample application to this repository? - 'n', + 'n', ]); // Assert. @@ -279,11 +279,11 @@ public function testConvertEnvironmentAliasToUuidArgument(): void $this->executeCommand(['environmentId' => $alias], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - '0', + '0', // Would you like to link the Cloud application Sample application to this repository? - 'n', + 'n', ]); // Assert. @@ -363,12 +363,12 @@ public function providerTestApiCommandDefinitionParameters(): array { $apiAccountsSshKeysListUsage = '--from="-7d" --to="-1d" --sort="field1,-field2" --limit="10" --offset="10"'; return [ - ['0', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:environments:domain-clear-caches', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 example.com'], - ['1', 'api:applications:find', 'get', 'da1c0a8e-ff69-45db-88fc-acd6d2affbb7'], - ['1', 'api:applications:find', 'get', 'myapp'], + ['0', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], + ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], + ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], + ['1', 'api:environments:domain-clear-caches', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 example.com'], + ['1', 'api:applications:find', 'get', 'da1c0a8e-ff69-45db-88fc-acd6d2affbb7'], + ['1', 'api:applications:find', 'get', 'myapp'], ]; } @@ -415,8 +415,8 @@ public function testModifiedParameterDescriptions(): void public function providerTestApiCommandDefinitionRequestBody(): array { return [ - ['api:accounts:ssh-key-create', 'post', 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChwPHzTTDKDpSbpa2+d22LcbQmsw92eLsUK3Fmei1fiGDkd34NsYCN8m7lsi3NbvdMS83CtPQPWiCveYPzFs1/hHc4PYj8opD2CNnr5iWVVbyaulCYHCgVv4aB/ojcexg8q483A4xJeF15TiCr/gu34rK6ucTvC/tn/rCwJBudczvEwt0klqYwv8Cl/ytaQboSuem5KgSjO3lMrb6CWtfSNhE43ZOw+UBFBqxIninN868vGMkIv9VY34Pwj54rPn/ItQd6Ef4B0KHHaGmzK0vfP+AK7FxNMoHnj3iYT33KZNqtDozdn5tYyH/bThPebEtgqUn+/w5l6wZIC/8zzvls/127ngHk+jNa0PlNyS2TxhPUK4NaPHIEnnrlp07JEYC4ImcBjaYCWAdcTcUkcJjwZQkN4bGmyO9cjICH98SdLD/HxqzTHeaYDbAX/Hu9HfaBb5dXLWsjw3Xc6hoVnUUZbMQyfgb0KgxDLh92eNGxJkpZiL0VDNOWCxDWsNpzwhLNkLqCvI6lyxiLaUzvJAk6dPaRhExmCbU1lDO2eR0FdSwC1TEhJOT9eDIK1r2hztZKs2oa5FNFfB/IFHVWasVFC9N2h/r/egB5zsRxC9MqBLRBq95NBxaRSFng6ML5WZSw41Qi4C/JWVm89rdj2WqScDHYyAdwyyppWU4T5c9Fmw== example@example.com"'], - ['api:environments:file-copy', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 --source="14-0c7e79ab-1c4a-424e-8446-76ae8be7e851"'], + ['api:accounts:ssh-key-create', 'post', 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChwPHzTTDKDpSbpa2+d22LcbQmsw92eLsUK3Fmei1fiGDkd34NsYCN8m7lsi3NbvdMS83CtPQPWiCveYPzFs1/hHc4PYj8opD2CNnr5iWVVbyaulCYHCgVv4aB/ojcexg8q483A4xJeF15TiCr/gu34rK6ucTvC/tn/rCwJBudczvEwt0klqYwv8Cl/ytaQboSuem5KgSjO3lMrb6CWtfSNhE43ZOw+UBFBqxIninN868vGMkIv9VY34Pwj54rPn/ItQd6Ef4B0KHHaGmzK0vfP+AK7FxNMoHnj3iYT33KZNqtDozdn5tYyH/bThPebEtgqUn+/w5l6wZIC/8zzvls/127ngHk+jNa0PlNyS2TxhPUK4NaPHIEnnrlp07JEYC4ImcBjaYCWAdcTcUkcJjwZQkN4bGmyO9cjICH98SdLD/HxqzTHeaYDbAX/Hu9HfaBb5dXLWsjw3Xc6hoVnUUZbMQyfgb0KgxDLh92eNGxJkpZiL0VDNOWCxDWsNpzwhLNkLqCvI6lyxiLaUzvJAk6dPaRhExmCbU1lDO2eR0FdSwC1TEhJOT9eDIK1r2hztZKs2oa5FNFfB/IFHVWasVFC9N2h/r/egB5zsRxC9MqBLRBq95NBxaRSFng6ML5WZSw41Qi4C/JWVm89rdj2WqScDHYyAdwyyppWU4T5c9Fmw== example@example.com"'], + ['api:environments:file-copy', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 --source="14-0c7e79ab-1c4a-424e-8446-76ae8be7e851"'], ]; } @@ -465,8 +465,8 @@ public function testOrganizationMemberDeleteByUserUuid(): void $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->executeCommand( [ - 'organizationUuid' => $orgId, - 'userUuid' => $memberUuid, + 'organizationUuid' => $orgId, + 'userUuid' => $memberUuid, ], ); @@ -493,8 +493,8 @@ public function testOrganizationMemberDeleteByUserEmail(): void $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->executeCommand( [ - 'organizationUuid' => $orgId, - 'userUuid' => $memberMail, + 'organizationUuid' => $orgId, + 'userUuid' => $memberMail, ], ); @@ -521,8 +521,8 @@ public function testOrganizationMemberDeleteInvalidEmail(): void $this->expectExceptionMessage('No matching user found in this organization'); $this->executeCommand( [ - 'organizationUuid' => $orgId, - 'userUuid' => $memberUuid, + 'organizationUuid' => $orgId, + 'userUuid' => $memberUuid, ], ); } @@ -543,8 +543,8 @@ public function testOrganizationMemberDeleteNoMembers(): void $this->expectExceptionMessage('Organization has no members'); $this->executeCommand( [ - 'organizationUuid' => $orgId, - 'userUuid' => $memberUuid, + 'organizationUuid' => $orgId, + 'userUuid' => $memberUuid, ], ); } diff --git a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php index 97f3b7a47..e057fc58e 100644 --- a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php +++ b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php @@ -40,7 +40,7 @@ public function testNoEnvAvailableCommand(): void $this->executeCommand( [ - 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', ], ); } @@ -65,7 +65,7 @@ public function testNoVcsAvailableCommand(): void $this->expectExceptionMessage('No branch or tag is available with this application.'); $this->executeCommand( [ - 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', ], ); } @@ -83,7 +83,7 @@ public function testShowVcsListCommand(): void $this->executeCommand( [ - 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', ], ); @@ -128,8 +128,8 @@ public function testNoDeployedVcs(): void $this->expectExceptionMessage('No branch or tag is deployed on any of the environment of this application.'); $this->executeCommand( [ - 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', - '--deployed', + 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + '--deployed', ], ); } @@ -147,8 +147,8 @@ public function testListOnlyDeployedVcs(): void $this->executeCommand( [ - 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', - '--deployed', + 'applicationUuid' => 'a47ac10b-58cc-4372-a567-0e02b2c3d470', + '--deployed', ], ); diff --git a/tests/phpunit/src/Commands/App/From/AbandonmentRecommendationTest.php b/tests/phpunit/src/Commands/App/From/AbandonmentRecommendationTest.php index 78c9e9092..c7bed4ba6 100644 --- a/tests/phpunit/src/Commands/App/From/AbandonmentRecommendationTest.php +++ b/tests/phpunit/src/Commands/App/From/AbandonmentRecommendationTest.php @@ -21,12 +21,12 @@ protected function setUp(): void // @see \Acquia\Cli\Tests\Commands\App\From\DefinedRecommendationTest::getTestConfigurations() // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $this->sut = DefinedRecommendation::createFromDefinition([ - 'package' => null, - 'note' => 'Example: The module bar is no longer required because its functionality has been incorporated into Drupal core.', - 'replaces' => [ - 'name' => 'bar', - ], - 'vetted' => true, + 'package' => null, + 'note' => 'Example: The module bar is no longer required because its functionality has been incorporated into Drupal core.', + 'replaces' => [ + 'name' => 'bar', + ], + 'vetted' => true, ]); // phpcs:enable } diff --git a/tests/phpunit/src/Commands/App/From/ConfigurationTest.php b/tests/phpunit/src/Commands/App/From/ConfigurationTest.php index b7d6071ea..128b6ca55 100644 --- a/tests/phpunit/src/Commands/App/From/ConfigurationTest.php +++ b/tests/phpunit/src/Commands/App/From/ConfigurationTest.php @@ -37,8 +37,8 @@ public function test(string $configuration, Exception $expected_exception): void public function getTestConfigurations(): array { return [ - 'bad JSON in configuration file' => ['{,}', new JsonException('Syntax error', JSON_ERROR_SYNTAX)], - 'empty configuration file' => [json_encode((object) []), new DomainException('Missing required key: rootPackageDefinition')], + 'bad JSON in configuration file' => ['{,}', new JsonException('Syntax error', JSON_ERROR_SYNTAX)], + 'empty configuration file' => [json_encode((object) []), new DomainException('Missing required key: rootPackageDefinition')], ]; } } diff --git a/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php b/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php index 7f4c1511b..36e09b5ac 100755 --- a/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php +++ b/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php @@ -51,127 +51,127 @@ public function getTestConfigurations(): array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return [ - 'config is not array' => [42, new NoRecommendation()], - 'empty array' => [[], new NoRecommendation()], - 'missing required key' => [ - ['package' => '', 'constraint' => ''], - new NoRecommendation(), - ], - 'key value does not match schema' => [ - ['package' => 42, 'constraint' => '', 'replaces' => ['name' => '']], - new NoRecommendation(), - ], - 'nested key value does not match schema' => [ - ['package' => '', 'constraint' => '', 'replaces' => ['name' => 42]], - new NoRecommendation(), - ], - 'invalid patches key' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'patches' => [ - 0 => 'https://example.com', - ], - 'replaces' => [ - 'name' => 'foo', - ], - ], - new NoRecommendation(), - ], - 'invalid patches key value' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'patches' => [ - 'A patch description' => true, - ], - 'replaces' => [ - 'name' => 'foo', - ], - ], - new NoRecommendation(), - ], - 'missing replaces key, not universal by default' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - ], - new NoRecommendation(), - ], - 'missing replaces key, explicitly not universal' => [ - [ - 'universal' => false, - 'package' => 'foo', - 'constraint' => '^1.42', - ], - new NoRecommendation(), - ], - 'valid config; does not apply' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'replaces' => [ - 'name' => 'foo', - ], - ], - new TestRecommendation(false, 'foo', '^1.42'), - ], - 'valid config; does apply; missing replaces key but universal is true' => [ - [ - 'universal' => true, - 'package' => 'foo', - 'constraint' => '^1.42', - ], - new TestRecommendation(true, 'foo', '^1.42'), - ], - 'valid config; does apply; no patches key' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'replaces' => [ - 'name' => 'bar', - ], - ], - new TestRecommendation(true, 'foo', '^1.42'), - ], - 'valid config; does apply; empty patches value' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'patches' => [], - 'replaces' => [ - 'name' => 'bar', - ], - ], - new TestRecommendation(true, 'foo', '^1.42'), - ], - 'valid config; does apply; has patches' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'patches' => [ - 'A patch description' => 'https://example.com/example.patch', - ], - 'install' => ['foo'], - 'replaces' => [ - 'name' => 'bar', - ], - ], - new TestRecommendation(true, 'foo', '^1.42', ['foo'], false, [ - 'A patch description' => 'https://example.com/example.patch', - ]), - ], - 'valid config; does apply; has null package property' => [ - [ - 'package' => null, - 'note' => 'Example: The module bar is no longer required because its functionality has been incorporated into Drupal core.', - 'replaces' => [ - 'name' => 'bar', - ], - 'vetted' => true, - ], - new TestRecommendation(true, TestRecommendation::ABANDON), - ], + 'config is not array' => [42, new NoRecommendation()], + 'empty array' => [[], new NoRecommendation()], + 'missing required key' => [ + ['package' => '', 'constraint' => ''], + new NoRecommendation(), + ], + 'key value does not match schema' => [ + ['package' => 42, 'constraint' => '', 'replaces' => ['name' => '']], + new NoRecommendation(), + ], + 'nested key value does not match schema' => [ + ['package' => '', 'constraint' => '', 'replaces' => ['name' => 42]], + new NoRecommendation(), + ], + 'invalid patches key' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'patches' => [ + 0 => 'https://example.com', + ], + 'replaces' => [ + 'name' => 'foo', + ], + ], + new NoRecommendation(), + ], + 'invalid patches key value' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'patches' => [ + 'A patch description' => true, + ], + 'replaces' => [ + 'name' => 'foo', + ], + ], + new NoRecommendation(), + ], + 'missing replaces key, not universal by default' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + ], + new NoRecommendation(), + ], + 'missing replaces key, explicitly not universal' => [ + [ + 'universal' => false, + 'package' => 'foo', + 'constraint' => '^1.42', + ], + new NoRecommendation(), + ], + 'valid config; does not apply' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'replaces' => [ + 'name' => 'foo', + ], + ], + new TestRecommendation(false, 'foo', '^1.42'), + ], + 'valid config; does apply; missing replaces key but universal is true' => [ + [ + 'universal' => true, + 'package' => 'foo', + 'constraint' => '^1.42', + ], + new TestRecommendation(true, 'foo', '^1.42'), + ], + 'valid config; does apply; no patches key' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'replaces' => [ + 'name' => 'bar', + ], + ], + new TestRecommendation(true, 'foo', '^1.42'), + ], + 'valid config; does apply; empty patches value' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'patches' => [], + 'replaces' => [ + 'name' => 'bar', + ], + ], + new TestRecommendation(true, 'foo', '^1.42'), + ], + 'valid config; does apply; has patches' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'patches' => [ + 'A patch description' => 'https://example.com/example.patch', + ], + 'install' => ['foo'], + 'replaces' => [ + 'name' => 'bar', + ], + ], + new TestRecommendation(true, 'foo', '^1.42', ['foo'], false, [ + 'A patch description' => 'https://example.com/example.patch', + ]), + ], + 'valid config; does apply; has null package property' => [ + [ + 'package' => null, + 'note' => 'Example: The module bar is no longer required because its functionality has been incorporated into Drupal core.', + 'replaces' => [ + 'name' => 'bar', + ], + 'vetted' => true, + ], + new TestRecommendation(true, TestRecommendation::ABANDON), + ], ]; // phpcs:enable } diff --git a/tests/phpunit/src/Commands/App/From/ProjectBuilderTest.php b/tests/phpunit/src/Commands/App/From/ProjectBuilderTest.php index f9d1c8f2a..244611f39 100644 --- a/tests/phpunit/src/Commands/App/From/ProjectBuilderTest.php +++ b/tests/phpunit/src/Commands/App/From/ProjectBuilderTest.php @@ -35,29 +35,29 @@ public function getTestResources(): array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys $test_cases = [ - 'simplest case, sanity check' => [ - json_encode([ - 'sourceModules' => [], - 'filePaths' => [ - 'public' => 'sites/default/files', - 'private' => null, - ], - 'rootPackageDefinition' => [], - ]), - json_encode([ - 'data' => [], - ]), - [ - 'installModules' => [], - 'filePaths' => [ - 'public' => 'sites/default/files', - 'private' => null, - ], - 'sourceModules' => [], - 'recommendations' => [], - 'rootPackageDefinition' => [], - ], - ], + 'simplest case, sanity check' => [ + json_encode([ + 'sourceModules' => [], + 'filePaths' => [ + 'public' => 'sites/default/files', + 'private' => null, + ], + 'rootPackageDefinition' => [], + ]), + json_encode([ + 'data' => [], + ]), + [ + 'installModules' => [], + 'filePaths' => [ + 'public' => 'sites/default/files', + 'private' => null, + ], + 'sourceModules' => [], + 'recommendations' => [], + 'rootPackageDefinition' => [], + ], + ], ]; // phpcs:enable return array_map(function (array $data) { diff --git a/tests/phpunit/src/Commands/App/From/RecommendationsTest.php b/tests/phpunit/src/Commands/App/From/RecommendationsTest.php index 54e6007ca..e60d65c5a 100644 --- a/tests/phpunit/src/Commands/App/From/RecommendationsTest.php +++ b/tests/phpunit/src/Commands/App/From/RecommendationsTest.php @@ -52,40 +52,40 @@ public function getTestConfigurations(): array { // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return [ - 'bad JSON in configuration file' => [ - '{,}', - static::NO_RECOMMENDATIONS, - ], - 'empty configuration file' => [ - json_encode((object) []), - static::NO_RECOMMENDATIONS, - ], - 'unexpected recommendations value' => [ - json_encode(['data' => true]), - static::NO_RECOMMENDATIONS, - ], - 'empty recommendations key' => [ - json_encode(['data' => []]), - static::NO_RECOMMENDATIONS, - ], - 'populated recommendations key with invalid item' => [ - json_encode(['recommendations' => [[]]]), - static::NO_RECOMMENDATIONS, - ], - 'populated recommendations key with valid item' => [ - json_encode([ - 'data' => [ - [ - 'package' => 'foo', - 'constraint' => '^1.42', - 'replaces' => [ - 'name' => 'foo', - ], - ], - ], - ]), - new TestRecommendation(true, 'foo', '^1.42'), - ], + 'bad JSON in configuration file' => [ + '{,}', + static::NO_RECOMMENDATIONS, + ], + 'empty configuration file' => [ + json_encode((object) []), + static::NO_RECOMMENDATIONS, + ], + 'unexpected recommendations value' => [ + json_encode(['data' => true]), + static::NO_RECOMMENDATIONS, + ], + 'empty recommendations key' => [ + json_encode(['data' => []]), + static::NO_RECOMMENDATIONS, + ], + 'populated recommendations key with invalid item' => [ + json_encode(['recommendations' => [[]]]), + static::NO_RECOMMENDATIONS, + ], + 'populated recommendations key with valid item' => [ + json_encode([ + 'data' => [ + [ + 'package' => 'foo', + 'constraint' => '^1.42', + 'replaces' => [ + 'name' => 'foo', + ], + ], + ], + ]), + new TestRecommendation(true, 'foo', '^1.42'), + ], ]; // phpcs:enable } diff --git a/tests/phpunit/src/Commands/App/LinkCommandTest.php b/tests/phpunit/src/Commands/App/LinkCommandTest.php index 85a26744c..83ecfb901 100644 --- a/tests/phpunit/src/Commands/App/LinkCommandTest.php +++ b/tests/phpunit/src/Commands/App/LinkCommandTest.php @@ -26,9 +26,9 @@ public function testLinkCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application. - 0, + 0, ]; $this->executeCommand([], $inputs); $output = $this->getDisplay(); diff --git a/tests/phpunit/src/Commands/App/LogTailCommandTest.php b/tests/phpunit/src/Commands/App/LogTailCommandTest.php index 6bd3d3a1e..dd9b3fd60 100644 --- a/tests/phpunit/src/Commands/App/LogTailCommandTest.php +++ b/tests/phpunit/src/Commands/App/LogTailCommandTest.php @@ -25,8 +25,8 @@ class LogTailCommandTest extends CommandTestBase public function providerLogTailCommand(): array { return [ - [0], - [null], + [0], + [null], ]; } @@ -64,15 +64,15 @@ public function testLogTailCommand(?int $stream): void $this->mockLogStreamRequest(); $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select environment. - 0, + 0, // Select log. - $stream, + $stream, ]); // Assert. @@ -114,15 +114,15 @@ public function testLogTailNode(): void $this->expectExceptionMessage('No compatible environments found'); $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select environment. - 0, + 0, // Select log. - 0, + 0, ]); } diff --git a/tests/phpunit/src/Commands/App/NewCommandTest.php b/tests/phpunit/src/Commands/App/NewCommandTest.php index 90b502fda..fe3499925 100644 --- a/tests/phpunit/src/Commands/App/NewCommandTest.php +++ b/tests/phpunit/src/Commands/App/NewCommandTest.php @@ -35,8 +35,8 @@ protected function createCommand(): CommandBase public function provideTestNewDrupalCommand(): array { return [ - [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project']], - [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project', 'test-dir']], + [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project']], + [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project', 'test-dir']], ]; } @@ -46,8 +46,8 @@ public function provideTestNewDrupalCommand(): array public function provideTestNewNextJsAppCommand(): array { return [ - [['acquia_next_acms' => 'acquia/next-acms']], - [['acquia_next_acms' => 'acquia/next-acms'], 'test-dir'], + [['acquia_next_acms' => 'acquia/next-acms']], + [['acquia_next_acms' => 'acquia/next-acms'], 'test-dir'], ]; } @@ -76,10 +76,10 @@ public function testNewDrupalCommand(array $package, string $directory = 'drupal $inputs = [ // Choose a starting project. - $project, + $project, ]; $this->executeCommand([ - 'directory' => $directory, + 'directory' => $directory, ], $inputs); $output = $this->getDisplay(); @@ -116,10 +116,10 @@ public function testNewNextJSAppCommand(array $package, string $directory = 'nex $inputs = [ // Choose a starting project. - $project, + $project, ]; $this->executeCommand([ - 'directory' => $directory, + 'directory' => $directory, ], $inputs); $output = $this->getDisplay(); @@ -137,11 +137,11 @@ protected function mockExecuteComposerCreate( string $project ): void { $command = [ - 'composer', - 'create-project', - $project, - $projectDir, - '--no-interaction', + 'composer', + 'create-project', + $project, + $projectDir, + '--no-interaction', ]; $localMachineHelper ->execute($command) @@ -155,11 +155,11 @@ protected function mockExecuteNpxCreate( ObjectProphecy $process, ): void { $command = [ - 'npx', - 'create-next-app', - '-e', - 'https://github.com/acquia/next-acms/tree/main/starters/basic-starter', - $projectDir, + 'npx', + 'create-next-app', + '-e', + 'https://github.com/acquia/next-acms/tree/main/starters/basic-starter', + $projectDir, ]; $localMachineHelper ->execute($command) @@ -173,9 +173,9 @@ protected function mockExecuteGitInit( ObjectProphecy $process ): void { $command = [ - 'git', - 'init', - '--initial-branch=main', + 'git', + 'init', + '--initial-branch=main', ]; $localMachineHelper ->execute($command, null, $projectDir) @@ -189,9 +189,9 @@ protected function mockExecuteGitAdd( ObjectProphecy $process ): void { $command = [ - 'git', - 'add', - '-A', + 'git', + 'add', + '-A', ]; $localMachineHelper ->execute($command, null, $projectDir) @@ -205,11 +205,11 @@ protected function mockExecuteGitCommit( ObjectProphecy $process ): void { $command = [ - 'git', - 'commit', - '--message', - 'Initial commit.', - '--quiet', + 'git', + 'commit', + '--message', + 'Initial commit.', + '--quiet', ]; $localMachineHelper ->execute($command, null, $projectDir) diff --git a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php index 77ce1750e..0b6385441 100644 --- a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php +++ b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php @@ -45,9 +45,9 @@ public function provideTestNewFromDrupal7Command(): array $cases = []; foreach ($case_directories as $case_directory) { $cases[basename($case_directory)] = [ - "$case_directory/extensions.json", - "$repo_root/config/from_d7_recommendations.json", - "$case_directory/expected.json", + "$case_directory/extensions.json", + "$repo_root/config/from_d7_recommendations.json", + "$case_directory/expected.json", ]; } return $cases; @@ -108,9 +108,9 @@ public function testNewFromDrupal7Command(string $extensions_json, string $recom $this->mockExecuteGitCommit($localMachineHelper, $race_condition_proof_tmpdir, $process); $this->executeCommand([ - '--directory' => $race_condition_proof_tmpdir, - '--recommendations' => $recommendations_json, - '--stored-analysis' => $extensions_json, + '--directory' => $race_condition_proof_tmpdir, + '--recommendations' => $recommendations_json, + '--stored-analysis' => $extensions_json, ]); $output = $this->getDisplay(); @@ -138,11 +138,11 @@ protected function mockExecuteComposerCreate( ObjectProphecy $process ): void { $command = [ - 'composer', - 'install', - '--working-dir', - $projectDir, - '--no-interaction', + 'composer', + 'install', + '--working-dir', + $projectDir, + '--no-interaction', ]; $localMachineHelper ->execute($command) @@ -156,10 +156,10 @@ protected function mockExecuteGitInit( ObjectProphecy $process ): void { $command = [ - 'git', - 'init', - '--initial-branch=main', - '--quiet', + 'git', + 'init', + '--initial-branch=main', + '--quiet', ]; $localMachineHelper ->execute($command, null, $projectDir) @@ -173,9 +173,9 @@ protected function mockExecuteGitAdd( ObjectProphecy $process ): void { $command = [ - 'git', - 'add', - '-A', + 'git', + 'add', + '-A', ]; $localMachineHelper ->execute($command, null, $projectDir) @@ -189,11 +189,11 @@ protected function mockExecuteGitCommit( ObjectProphecy $process ): void { $command = [ - 'git', - 'commit', - '--message', - "Generated by Acquia CLI's app:new:from:drupal7.", - '--quiet', + 'git', + 'commit', + '--message', + "Generated by Acquia CLI's app:new:from:drupal7.", + '--quiet', ]; $localMachineHelper ->execute($command, null, $projectDir) diff --git a/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php b/tests/phpunit/src/Commands/App/TaskWaitCommandTest.php index 0549a951f..3b1942c4e 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 $notificationUuid = '1bd3487e-71d1-4fca-a2d9-5f969b3d35c1'; $this->mockRequest('getNotificationByUuid', $notificationUuid); $this->executeCommand([ - 'notification-uuid' => $notification, + 'notification-uuid' => $notification, ]); $output = $this->getDisplay(); @@ -53,7 +53,7 @@ function ($response): void { } ); $this->executeCommand([ - 'notification-uuid' => $notificationUuid, + 'notification-uuid' => $notificationUuid, ]); self::assertStringContainsString(' [ERROR] The task with notification uuid 1bd3487e-71d1-4fca-a2d9-5f969b3d35c1 failed', $this->getDisplay()); @@ -68,14 +68,14 @@ function ($response): void { public function providerTestTaskWaitCommand(): array { return [ - [ - '1bd3487e-71d1-4fca-a2d9-5f969b3d35c1', - ], - [ - 'https://cloud.acquia.com/api/notifications/1bd3487e-71d1-4fca-a2d9-5f969b3d35c1', - ], - [ - <<<'EOT' + [ + '1bd3487e-71d1-4fca-a2d9-5f969b3d35c1', + ], + [ + 'https://cloud.acquia.com/api/notifications/1bd3487e-71d1-4fca-a2d9-5f969b3d35c1', + ], + [ + <<<'EOT' { "message": "Caches are being cleared.", "_links": { @@ -88,10 +88,10 @@ public function providerTestTaskWaitCommand(): array } } EOT, - ], - [ - '"1bd3487e-71d1-4fca-a2d9-5f969b3d35c1"', - ], + ], + [ + '"1bd3487e-71d1-4fca-a2d9-5f969b3d35c1"', + ], ]; } @@ -120,7 +120,7 @@ public function testTaskWaitCommandWithInvalidJson(string $notification): void { $this->expectException(AcquiaCliException::class); $this->executeCommand([ - 'notification-uuid' => $notification, + 'notification-uuid' => $notification, ]); } @@ -130,8 +130,8 @@ public function testTaskWaitCommandWithInvalidJson(string $notification): void public function providerTestTaskWaitCommandWithInvalidJson(): array { return [ - [ - <<<'EOT' + [ + <<<'EOT' { "message": "Caches are being cleared.", "_links": { @@ -147,9 +147,9 @@ public function providerTestTaskWaitCommandWithInvalidJson(): array } } EOT, - ], - [ - <<<'EOT' + ], + [ + <<<'EOT' { "message": "Caches are being cleared.", "_links": { @@ -159,10 +159,10 @@ public function providerTestTaskWaitCommandWithInvalidJson(): array } } EOT, - ], - [ - '"11bd3487e-71d1-4fca-a2d9-5f969b3d35c1"', - ], + ], + [ + '"11bd3487e-71d1-4fca-a2d9-5f969b3d35c1"', + ], ]; } } diff --git a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php index 2cd9b3791..373342fca 100644 --- a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php +++ b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php @@ -48,10 +48,10 @@ public function testArchiveExport(): void $inputs = [ // ... Do you want to continue? (yes/no) [yes] - 'y', + 'y', ]; $this->executeCommand([ - 'destination-dir' => $destinationDir, + 'destination-dir' => $destinationDir, ], $inputs); $output = $this->getDisplay(); diff --git a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php index 32ae7560d..0a1c9c2a7 100644 --- a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php +++ b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php @@ -62,18 +62,18 @@ public function providerTestAuthLoginInvalidInputCommand(): Generator { yield [ - [], - ['--key' => 'no spaces are allowed' , '--secret' => $this->secret], + [], + ['--key' => 'no spaces are allowed' , '--secret' => $this->secret], ]; yield [ - [], - ['--key' => 'shorty' , '--secret' => $this->secret], + [], + ['--key' => 'shorty' , '--secret' => $this->secret], ]; yield [ - [], - ['--key' => ' ', '--secret' => $this->secret], + [], + ['--key' => ' ', '--secret' => $this->secret], ]; } @@ -95,14 +95,14 @@ public function testAuthLoginInvalidDatastore(): void $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); $this->removeMockCloudConfigFile(); $data = [ - 'acli_key' => 'key2', - 'keys' => [ - 'key1' => [ - 'label' => 'foo', - 'secret' => 'foo', - 'uuid' => 'foo', - ], - ], + 'acli_key' => 'key2', + 'keys' => [ + 'key1' => [ + 'label' => 'foo', + 'secret' => 'foo', + 'uuid' => 'foo', + ], + ], ]; $this->fs->dumpFile($this->cloudConfigFilepath, json_encode($data)); $this->expectException(AcquiaCliException::class); diff --git a/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php b/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php index c63b13e59..309330607 100644 --- a/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php +++ b/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php @@ -34,14 +34,14 @@ public function testAuthLogoutInvalidDatastore(): void $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); $this->removeMockCloudConfigFile(); $data = [ - 'acli_key' => 'key2', - 'keys' => [ - 'key1' => [ - 'label' => 'foo', - 'secret' => 'foo', - 'uuid' => 'foo', - ], - ], + 'acli_key' => 'key2', + 'keys' => [ + 'key1' => [ + 'label' => 'foo', + 'secret' => 'foo', + 'uuid' => 'foo', + ], + ], ]; $this->fs->dumpFile($this->cloudConfigFilepath, json_encode($data)); $this->expectException(AcquiaCliException::class); diff --git a/tests/phpunit/src/Commands/ClearCacheCommandTest.php b/tests/phpunit/src/Commands/ClearCacheCommandTest.php index 535d648da..f972c8ae9 100644 --- a/tests/phpunit/src/Commands/ClearCacheCommandTest.php +++ b/tests/phpunit/src/Commands/ClearCacheCommandTest.php @@ -48,7 +48,7 @@ public function testAliasesAreCached(): void $args = ['applicationUuid' => $alias]; $inputs = [ // Would you like to link the Cloud application Sample application to this repository? - 'n', + 'n', ]; $this->executeCommand($args, $inputs); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php index 8634a089f..6b825fe33 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php @@ -33,10 +33,10 @@ protected function createCommand(): CommandBase public function providerTestPhpVersionFailure(): array { return [ - ['', ValidatorException::class], - ['8', ValidatorException::class], - ['8 1', ValidatorException::class], - ['ABC', ValidatorException::class], + ['', ValidatorException::class], + ['8', ValidatorException::class], + ['8 1', ValidatorException::class], + ['ABC', ValidatorException::class], ]; } @@ -49,8 +49,8 @@ public function testPhpVersionFailure(mixed $phpVersion): void { $this->expectException(ValidatorException::class); $this->executeCommand([ - 'applicationUuid' => self::$applicationUuid, - 'php-version' => $phpVersion, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => $phpVersion, ]); } @@ -72,10 +72,10 @@ public function testCiCdNotEnabled(): void $this->command->setGitLabClient($gitlabClient->reveal()); $this->executeCommand([ - '--gitlab-host-name' => $this->gitLabHost, - '--gitlab-token' => $this->gitLabToken, - 'applicationUuid' => self::$applicationUuid, - 'php-version' => '8.1', + '--gitlab-host-name' => $this->gitLabHost, + '--gitlab-token' => $this->gitLabToken, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => '8.1', ]); $output = $this->getDisplay(); @@ -105,10 +105,10 @@ public function testPhpVersionAddFail(): void $gitlabClient->projects()->willReturn($projects); $this->command->setGitLabClient($gitlabClient->reveal()); $this->executeCommand([ - '--gitlab-host-name' => $this->gitLabHost, - '--gitlab-token' => $this->gitLabToken, - 'applicationUuid' => self::$applicationUuid, - 'php-version' => '8.1', + '--gitlab-host-name' => $this->gitLabHost, + '--gitlab-token' => $this->gitLabToken, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => '8.1', ]); $output = $this->getDisplay(); @@ -138,10 +138,10 @@ public function testPhpVersionAdd(): void $this->command->setGitLabClient($gitlabClient->reveal()); $this->executeCommand([ - '--gitlab-host-name' => $this->gitLabHost, - '--gitlab-token' => $this->gitLabToken, - 'applicationUuid' => self::$applicationUuid, - 'php-version' => '8.1', + '--gitlab-host-name' => $this->gitLabHost, + '--gitlab-token' => $this->gitLabToken, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => '8.1', ]); $output = $this->getDisplay(); @@ -166,12 +166,12 @@ public function testPhpVersionUpdateFail(): void $variables = $this->getMockGitLabVariables(); $variables[] = [ - 'environment_scope' => '*', - 'key' => 'PHP_VERSION', - 'masked' => false, - 'protected' => false, - 'value' => '8.1', - 'variable_type' => 'env_var', + 'environment_scope' => '*', + 'key' => 'PHP_VERSION', + 'masked' => false, + 'protected' => false, + 'value' => '8.1', + 'variable_type' => 'env_var', ]; $projects->variables($this->gitLabProjectId)->willReturn($variables); $projects->updateVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string')) @@ -180,10 +180,10 @@ public function testPhpVersionUpdateFail(): void $gitlabClient->projects()->willReturn($projects); $this->command->setGitLabClient($gitlabClient->reveal()); $this->executeCommand([ - '--gitlab-host-name' => $this->gitLabHost, - '--gitlab-token' => $this->gitLabToken, - 'applicationUuid' => self::$applicationUuid, - 'php-version' => '8.1', + '--gitlab-host-name' => $this->gitLabHost, + '--gitlab-token' => $this->gitLabToken, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => '8.1', ]); $output = $this->getDisplay(); @@ -208,12 +208,12 @@ public function testPhpVersionUpdate(): void $variables = $this->getMockGitLabVariables(); $variables[] = [ - 'environment_scope' => '*', - 'key' => 'PHP_VERSION', - 'masked' => false, - 'protected' => false, - 'value' => '8.1', - 'variable_type' => 'env_var', + 'environment_scope' => '*', + 'key' => 'PHP_VERSION', + 'masked' => false, + 'protected' => false, + 'value' => '8.1', + 'variable_type' => 'env_var', ]; $projects->variables($this->gitLabProjectId)->willReturn($variables); $projects->updateVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string')); @@ -222,10 +222,10 @@ public function testPhpVersionUpdate(): void $this->command->setGitLabClient($gitlabClient->reveal()); $this->executeCommand([ - '--gitlab-host-name' => $this->gitLabHost, - '--gitlab-token' => $this->gitLabToken, - 'applicationUuid' => self::$applicationUuid, - 'php-version' => '8.1', + '--gitlab-host-name' => $this->gitLabHost, + '--gitlab-token' => $this->gitLabToken, + 'applicationUuid' => self::$applicationUuid, + 'php-version' => '8.1', ]); $output = $this->getDisplay(); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php index f04927bb5..e37f022a1 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php @@ -53,24 +53,24 @@ protected function createCommand(): CommandBase public function providerTestCommand(): array { return [ - [ + [ // One project. - [$this->getMockedGitLabProject($this->gitLabProjectId)], + [$this->getMockedGitLabProject($this->gitLabProjectId)], // Inputs. - [ + [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // @todo - '0', + '0', // Do you want to continue? - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], ]; } @@ -97,48 +97,48 @@ public function testCommand(mixed $mockedGitlabProjects, mixed $inputs, mixed $a $this->mockGitLabPermissionsRequest($this::$applicationUuid); $projects = $this->mockGetGitLabProjects($this::$applicationUuid, $this->gitLabProjectId, $mockedGitlabProjects); $gitlabCicdVariables = [ - [ - 'key' => 'ACQUIA_APPLICATION_UUID', - 'masked' => true, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', - 'masked' => true, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_NAME', - 'masked' => true, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', - 'masked' => true, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], - [ - 'key' => 'PHP_VERSION', - 'masked' => false, - 'protected' => false, - 'value' => null, - 'variable_type' => 'env_var', - ], + [ + 'key' => 'ACQUIA_APPLICATION_UUID', + 'masked' => true, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', + 'masked' => true, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_NAME', + 'masked' => true, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'ACQUIA_GLAB_TOKEN_SECRET', + 'masked' => true, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], + [ + 'key' => 'PHP_VERSION', + 'masked' => false, + 'protected' => false, + 'value' => null, + 'variable_type' => 'env_var', + ], ]; $projects->variables($this->gitLabProjectId)->willReturn($gitlabCicdVariables); $projects->update($this->gitLabProjectId, Argument::type('array')); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index 531a80f0e..52265c6e5 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -58,230 +58,230 @@ protected function createCommand(): CommandBase public function providerTestCommand(): array { return [ - [ + [ // One project. - [$this->getMockedGitLabProject($this->gitLabProjectId)], + [$this->getMockedGitLabProject($this->gitLabProjectId)], // Inputs. - [ + [ // Do you want to continue? - 'y', + 'y', // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - // Two projects. - [ - [$this->getMockedGitLabProject($this->gitLabProjectId), $this->getMockedGitLabProject($this->gitLabProjectId)], - // Inputs. - [ - // Found multiple projects that could match the Sample application 1 application. Choose which one to configure. - '0', - // Do you want to continue? - 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Select a project type Drupal_project. - '0', - // Select PHP version 8.1. - '0', - // Do you want to continue? - 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Select a project type Drupal_project. - '0', - // Select PHP version 8.2. - '1', - // Do you want to continue? - 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Select a project type Node_project. - '1', - // Select NODE version 18.17.1. - '0', - // Do you want to continue? - 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Select a project type Node_project. - '1', - // Select NODE version 20.5.1. - '1', - // Do you want to continue? - 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'n', - // Choose project. - '0', - // Do you want to continue? - 'y', - ], - // Args. - [ - '--key' => $this->key, - '--secret' => $this->secret, - ], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Enter Cloud Key. - $this->key, - // Enter Cloud secret,. - $this->secret, - // Select a project type Drupal_project. - '0', - // Select PHP version 8.1. - '0', - // Do you want to continue? - 'y', - ], - // Args. - [], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Enter Cloud Key. - $this->key, - // Enter Cloud secret,. - $this->secret, - // Select a project type Node_project. - '1', - // Select NODE version 18.17.1. - '0', - // Do you want to continue? - 'y', - ], - // Args. - [], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Enter Cloud Key. - $this->key, - // Enter Cloud secret,. - $this->secret, - // Select a project type Drupal_project. - '0', - // Select PHP version 8.2. - '1', - // Do you want to continue? - 'y', - ], - // Args. - [], - ], - [ - // No projects. - [], - // Inputs. - [ - // 'Would you like to create a new Code Studio project? - 'y', - // Enter Cloud Key. - $this->key, - // Enter Cloud secret,. - $this->secret, - // Select a project type Node_project. - '1', - // Select NODE version 20.5.1. - '1', - // Do you want to continue? - 'y', - ], - // Args. - [], - ], + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + // Two projects. + [ + [$this->getMockedGitLabProject($this->gitLabProjectId), $this->getMockedGitLabProject($this->gitLabProjectId)], + // Inputs. + [ + // Found multiple projects that could match the Sample application 1 application. Choose which one to configure. + '0', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Select a project type Drupal_project. + '0', + // Select PHP version 8.1. + '0', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Select a project type Drupal_project. + '0', + // Select PHP version 8.2. + '1', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Select a project type Node_project. + '1', + // Select NODE version 18.17.1. + '0', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Select a project type Node_project. + '1', + // Select NODE version 20.5.1. + '1', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'n', + // Choose project. + '0', + // Do you want to continue? + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Enter Cloud Key. + $this->key, + // Enter Cloud secret,. + $this->secret, + // Select a project type Drupal_project. + '0', + // Select PHP version 8.1. + '0', + // Do you want to continue? + 'y', + ], + // Args. + [], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Enter Cloud Key. + $this->key, + // Enter Cloud secret,. + $this->secret, + // Select a project type Node_project. + '1', + // Select NODE version 18.17.1. + '0', + // Do you want to continue? + 'y', + ], + // Args. + [], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Enter Cloud Key. + $this->key, + // Enter Cloud secret,. + $this->secret, + // Select a project type Drupal_project. + '0', + // Select PHP version 8.2. + '1', + // Do you want to continue? + 'y', + ], + // Args. + [], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Enter Cloud Key. + $this->key, + // Enter Cloud secret,. + $this->secret, + // Select a project type Node_project. + '1', + // Select NODE version 20.5.1. + '1', + // Do you want to continue? + 'y', + ], + // Args. + [], + ], ]; } @@ -301,21 +301,21 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a $projects = $this->mockGetGitLabProjects($this::$applicationUuid, $this->gitLabProjectId, $mockedGitlabProjects); $parameters = [ - 'container_registry_access_level' => 'disabled', - 'default_branch' => 'main', - 'description' => 'Source repository for Acquia Cloud Platform application a47ac10b-58cc-4372-a567-0e02b2c3d470', - 'initialize_with_readme' => true, - 'namespace_id' => 47, - 'topics' => 'Acquia Cloud Application', + 'container_registry_access_level' => 'disabled', + 'default_branch' => 'main', + 'description' => 'Source repository for Acquia Cloud Platform application a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'initialize_with_readme' => true, + 'namespace_id' => 47, + 'topics' => 'Acquia Cloud Application', ]; $projects->create('Sample-application-1', $parameters)->willReturn($this->getMockedGitLabProject($this->gitLabProjectId)); $this->mockGitLabProjectsTokens($projects); $parameters = [ - 'container_registry_access_level' => 'disabled', - 'default_branch' => 'main', - 'description' => 'Source repository for Acquia Cloud Platform application a47ac10b-58cc-4372-a567-0e02b2c3d470', - 'initialize_with_readme' => true, - 'topics' => 'Acquia Cloud Application', + 'container_registry_access_level' => 'disabled', + 'default_branch' => 'main', + 'description' => 'Source repository for Acquia Cloud Platform application a47ac10b-58cc-4372-a567-0e02b2c3d470', + 'initialize_with_readme' => true, + 'topics' => 'Acquia Cloud Application', ]; $projects->update($this->gitLabProjectId, $parameters)->shouldBeCalled(); $projects->uploadAvatar( @@ -326,7 +326,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a if ($inputs[0] === 'y' && ($inputs[1] === '1' || (array_key_exists(3, $inputs) && $inputs[3] === '1'))) { $parameters = [ - 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', + 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', ]; $projects->update($this->gitLabProjectId, $parameters)->shouldBeCalled(); } else { @@ -335,18 +335,18 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a $pipeline = ['id' => 1]; $parameters = [ // Every Thursday at midnight. - 'cron' => '0 0 * * 4', - 'description' => 'Code Studio Automatic Updates', - 'ref' => 'master', + 'cron' => '0 0 * * 4', + 'description' => 'Code Studio Automatic Updates', + 'ref' => 'master', ]; $schedules->create($this->gitLabProjectId, $parameters)->willReturn($pipeline); $schedules->addVariable($this->gitLabProjectId, $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', - 'value' => 'true', + 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', + 'value' => 'true', ])->shouldBeCalled(); $schedules->addVariable($this->gitLabProjectId, $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', - 'value' => 'true', + 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', + 'value' => 'true', ])->shouldBeCalled(); $gitlabClient->schedules()->willReturn($schedules->reveal()); } @@ -393,8 +393,8 @@ public function testInvalidGitLabCredentials(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to authenticate with Code Studio'); $this->executeCommand([ - '--key' => $this->key, - '--secret' => $this->secret, + '--key' => $this->key, + '--secret' => $this->secret, ]); } @@ -411,28 +411,28 @@ public function testMissingGitLabCredentials(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Could not determine GitLab token'); $this->executeCommand([ - '--key' => $this->key, - '--secret' => $this->secret, + '--key' => $this->key, + '--secret' => $this->secret, ]); } protected function mockGitLabProjectsTokens(ObjectProphecy $projects): void { $tokens = [ - 0 => [ - 'access_level' => 40, - 'active' => true, - 'created_at' => '2021-12-28T20:08:21.629Z', - 'expires_at' => new DateTime('+365 days'), - 'id' => $this->gitLabTokenId, - 'name' => 'acquia-codestudio', - 'revoked' => false, - 'scopes' => [ - 0 => 'api', - 1 => 'write_repository', - ], - 'user_id' => 154, - ], + 0 => [ + 'access_level' => 40, + 'active' => true, + 'created_at' => '2021-12-28T20:08:21.629Z', + 'expires_at' => new DateTime('+365 days'), + 'id' => $this->gitLabTokenId, + 'name' => 'acquia-codestudio', + 'revoked' => false, + 'scopes' => [ + 0 => 'api', + 1 => 'write_repository', + ], + 'user_id' => 154, + ], ]; $projects->projectAccessTokens($this->gitLabProjectId)->willReturn($tokens)->shouldBeCalled(); $projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId)->shouldBeCalled(); @@ -446,10 +446,10 @@ protected function mockGetCurrentBranchName(mixed $localMachineHelper): void $process = $this->mockProcess(); $process->getOutput()->willReturn('main'); $localMachineHelper->execute([ - 'git', - 'rev-parse', - '--abbrev-ref', - 'HEAD', + 'git', + 'rev-parse', + '--abbrev-ref', + 'HEAD', ], null, null, false)->willReturn($process->reveal()); } @@ -457,60 +457,60 @@ protected function mockGitLabGroups(ObjectProphecy $gitlabClient): void { $groups = $this->prophet->prophesize(Groups::class); $groups->all(Argument::type('array'))->willReturn([ - 0 => [ - 'auto_devops_enabled' => null, - 'avatar_url' => null, - 'created_at' => '2021-11-16T18:54:31.275Z', - 'default_branch_protection' => 2, - 'description' => '', - 'emails_disabled' => null, - 'full_name' => 'awesome-demo', - 'full_path' => 'awesome-demo', - 'id' => 47, - 'ldap_access' => null, - 'ldap_cn' => null, - 'lfs_enabled' => true, - 'marked_for_deletion_on' => null, - 'mentions_disabled' => null, - 'name' => 'awesome-demo', - 'parent_id' => null, - 'path' => 'awesome-demo', - 'project_creation_level' => 'developer', - 'request_access_enabled' => true, - 'require_two_factor_authentication' => false, - 'share_with_group_lock' => false, - 'subgroup_creation_level' => 'maintainer', - 'two_factor_grace_period' => 48, - 'visibility' => 'private', - 'web_url' => 'https://code.cloudservices.acquia.io/groups/awesome-demo', - ], - 1 => [ - 'auto_devops_enabled' => null, - 'avatar_url' => null, - 'created_at' => '2021-12-14T18:49:50.724Z', - 'default_branch_protection' => 2, - 'description' => '', - 'emails_disabled' => null, - 'full_name' => 'Nestle', - 'full_path' => 'nestle', - 'id' => 68, - 'ldap_access' => null, - 'ldap_cn' => null, - 'lfs_enabled' => true, - 'marked_for_deletion_on' => null, - 'mentions_disabled' => null, - 'name' => 'Nestle', - 'parent_id' => null, - 'path' => 'nestle', - 'project_creation_level' => 'developer', - 'request_access_enabled' => true, - 'require_two_factor_authentication' => false, - 'share_with_group_lock' => false, - 'subgroup_creation_level' => 'maintainer', - 'two_factor_grace_period' => 48, - 'visibility' => 'private', - 'web_url' => 'https://code.cloudservices.acquia.io/groups/nestle', - ], + 0 => [ + 'auto_devops_enabled' => null, + 'avatar_url' => null, + 'created_at' => '2021-11-16T18:54:31.275Z', + 'default_branch_protection' => 2, + 'description' => '', + 'emails_disabled' => null, + 'full_name' => 'awesome-demo', + 'full_path' => 'awesome-demo', + 'id' => 47, + 'ldap_access' => null, + 'ldap_cn' => null, + 'lfs_enabled' => true, + 'marked_for_deletion_on' => null, + 'mentions_disabled' => null, + 'name' => 'awesome-demo', + 'parent_id' => null, + 'path' => 'awesome-demo', + 'project_creation_level' => 'developer', + 'request_access_enabled' => true, + 'require_two_factor_authentication' => false, + 'share_with_group_lock' => false, + 'subgroup_creation_level' => 'maintainer', + 'two_factor_grace_period' => 48, + 'visibility' => 'private', + 'web_url' => 'https://code.cloudservices.acquia.io/groups/awesome-demo', + ], + 1 => [ + 'auto_devops_enabled' => null, + 'avatar_url' => null, + 'created_at' => '2021-12-14T18:49:50.724Z', + 'default_branch_protection' => 2, + 'description' => '', + 'emails_disabled' => null, + 'full_name' => 'Nestle', + 'full_path' => 'nestle', + 'id' => 68, + 'ldap_access' => null, + 'ldap_cn' => null, + 'lfs_enabled' => true, + 'marked_for_deletion_on' => null, + 'mentions_disabled' => null, + 'name' => 'Nestle', + 'parent_id' => null, + 'path' => 'nestle', + 'project_creation_level' => 'developer', + 'request_access_enabled' => true, + 'require_two_factor_authentication' => false, + 'share_with_group_lock' => false, + 'subgroup_creation_level' => 'maintainer', + 'two_factor_grace_period' => 48, + 'visibility' => 'private', + 'web_url' => 'https://code.cloudservices.acquia.io/groups/nestle', + ], ]); $gitlabClient->groups()->willReturn($groups->reveal()); } @@ -519,20 +519,20 @@ protected function mockGitLabNamespaces(ObjectProphecy $gitlabClient): void { $namespaces = $this->prophet->prophesize(ProjectNamespaces::class); $namespaces->show(Argument::type('string'))->willReturn([ - 'avatar_url' => 'https://secure.gravatar.com/avatar/5ee7b8ad954bf7156e6eb57a45d60dec?s=80&d=identicon', - 'billable_members_count' => 1, - 'full_path' => 'matthew.grasmick', - 'id' => 48, - 'kind' => 'user', - 'max_seats_used' => 0, - 'name' => 'Matthew Grasmick', - 'parent_id' => null, - 'path' => 'matthew.grasmick', - 'plan' => 'default', - 'seats_in_use' => 0, - 'trial' => false, - 'trial_ends_on' => null, - 'web_url' => 'https://code.cloudservices.acquia.io/matthew.grasmick', + 'avatar_url' => 'https://secure.gravatar.com/avatar/5ee7b8ad954bf7156e6eb57a45d60dec?s=80&d=identicon', + 'billable_members_count' => 1, + 'full_path' => 'matthew.grasmick', + 'id' => 48, + 'kind' => 'user', + 'max_seats_used' => 0, + 'name' => 'Matthew Grasmick', + 'parent_id' => null, + 'path' => 'matthew.grasmick', + 'plan' => 'default', + 'seats_in_use' => 0, + 'trial' => false, + 'trial_ends_on' => null, + 'web_url' => 'https://code.cloudservices.acquia.io/matthew.grasmick', ]); $gitlabClient->namespaces()->willReturn($namespaces->reveal()); } diff --git a/tests/phpunit/src/Commands/CommandBaseTest.php b/tests/phpunit/src/Commands/CommandBaseTest.php index 49e0d7853..2dfee6b90 100644 --- a/tests/phpunit/src/Commands/CommandBaseTest.php +++ b/tests/phpunit/src/Commands/CommandBaseTest.php @@ -31,7 +31,7 @@ public function testUnauthenticatedFailure(): void $inputs = [ // Would you like to share anonymous performance usage and data? - 'n', + 'n', ]; $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('This machine is not yet authenticated with the Cloud Platform.'); @@ -53,8 +53,8 @@ public function testCloudAppFromLocalConfig(): void public function providerTestCloudAppUuidArg(): array { return [ - ['a47ac10b-58cc-4372-a567-0e02b2c3d470'], - ['165c887b-7633-4f64-799d-a5d4669c768e'], + ['a47ac10b-58cc-4372-a567-0e02b2c3d470'], + ['165c887b-7633-4f64-799d-a5d4669c768e'], ]; } @@ -74,8 +74,8 @@ public function testCloudAppUuidArg(string $uuid): void public function providerTestInvalidCloudAppUuidArg(): array { return [ - ['a47ac10b-58cc-4372-a567-0e02b2c3d4', 'This value should have exactly 36 characters.'], - ['a47ac10b-58cc-4372-a567-0e02b2c3d47z', 'This is not a valid UUID.'], + ['a47ac10b-58cc-4372-a567-0e02b2c3d4', 'This value should have exactly 36 characters.'], + ['a47ac10b-58cc-4372-a567-0e02b2c3d47z', 'This is not a valid UUID.'], ]; } @@ -95,9 +95,9 @@ public function testInvalidCloudAppUuidArg(string $uuid, string $message): void public function providerTestInvalidCloudEnvironmentAlias(): array { return [ - ['bl.a', 'This value is too short. It should have 5 characters or more.'], - ['blarg', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], - ['12345', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], + ['bl.a', 'This value is too short. It should have 5 characters or more.'], + ['blarg', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], + ['12345', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], ]; } diff --git a/tests/phpunit/src/Commands/DocsCommandTest.php b/tests/phpunit/src/Commands/DocsCommandTest.php index b69936a1a..7158cd283 100644 --- a/tests/phpunit/src/Commands/DocsCommandTest.php +++ b/tests/phpunit/src/Commands/DocsCommandTest.php @@ -39,78 +39,78 @@ public function testDocsCommand(int $input, string $expectedOutput): void 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', - ], + [ + 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/Email/ConfigurePlatformEmailCommandTest.php b/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php index d935b4596..663cb6963 100644 --- a/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php +++ b/tests/phpunit/src/Commands/Email/ConfigurePlatformEmailCommandTest.php @@ -91,98 +91,98 @@ public function providerTestConfigurePlatformEmail(): array { return [ - [ - 'test.com', - 'zone', - self::ZONE_TEST_OUTPUT, - [ + [ + 'test.com', + 'zone', + self::ZONE_TEST_OUTPUT, + [ // What's the domain name you'd like to register? - 'test.com', + 'test.com', // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - '0', - ], - // Status code. - 0, - // Expected text. - ["You're all set to start using Platform Email!"], - // Domain registration responses. - "200", - ], - [ - 'test.com', - 'yaml', - self::YAML_TEST_OUTPUT, - [ - // What's the domain name you'd like to register? - 'test.com', - // Select a Cloud Platform subscription. - '0', - // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '1', - // Have you finished providing the DNS records to your DNS provider? - 'n', - ], - // Status code. - 1, - // Expected text. - ["Make sure to give these records to your DNS provider"], - // Domain registration responses. - "404", - ], - [ - 'test.com', - 'json', - self::JSON_TEST_OUTPUT, - [ - // What's the domain name you'd like to register? - 'test.com', - // Select a Cloud Platform subscription. - '0', - // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '2', - // Have you finished providing the DNS records to your DNS provider? - 'y', - // Would you like to retry verification? - 'n', - ], - // Status code. - 1, - // Expected text. - ["Verification pending...", "Check your DNS records with your DNS provider"], - // Domain registration responses. - "202", - ], - [ - 'test.com', - 'zone', - self::ZONE_TEST_OUTPUT, - [ - // What's the domain name you'd like to register? - 'test.com', - // Select a Cloud Platform subscription. - '0', - // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', - // Have you finished providing the DNS records to your DNS provider? - 'y', - // Would you like to refresh? - 'y', - // Would you like to re-check domain verification? - 'n', - ], - // Status code. - 1, - // Expected text. - ["Refreshing...", "Check your DNS records with your DNS provider"], - // Domain registration responses. - "404", - ], + '0', + ], + // Status code. + 0, + // Expected text. + ["You're all set to start using Platform Email!"], + // Domain registration responses. + "200", + ], + [ + 'test.com', + 'yaml', + self::YAML_TEST_OUTPUT, + [ + // What's the domain name you'd like to register? + 'test.com', + // Select a Cloud Platform subscription. + '0', + // Would you like your DNS records in BIND Zone File, JSON, or YAML format? + '1', + // Have you finished providing the DNS records to your DNS provider? + 'n', + ], + // Status code. + 1, + // Expected text. + ["Make sure to give these records to your DNS provider"], + // Domain registration responses. + "404", + ], + [ + 'test.com', + 'json', + self::JSON_TEST_OUTPUT, + [ + // What's the domain name you'd like to register? + 'test.com', + // Select a Cloud Platform subscription. + '0', + // Would you like your DNS records in BIND Zone File, JSON, or YAML format? + '2', + // Have you finished providing the DNS records to your DNS provider? + 'y', + // Would you like to retry verification? + 'n', + ], + // Status code. + 1, + // Expected text. + ["Verification pending...", "Check your DNS records with your DNS provider"], + // Domain registration responses. + "202", + ], + [ + 'test.com', + 'zone', + self::ZONE_TEST_OUTPUT, + [ + // What's the domain name you'd like to register? + 'test.com', + // Select a Cloud Platform subscription. + '0', + // Would you like your DNS records in BIND Zone File, JSON, or YAML format? + '0', + // Have you finished providing the DNS records to your DNS provider? + 'y', + // Would you like to refresh? + 'y', + // Would you like to re-check domain verification? + 'n', + ], + // Status code. + 1, + // Expected text. + ["Refreshing...", "Check your DNS records with your DNS provider"], + // Domain registration responses. + "404", + ], ]; } @@ -192,52 +192,52 @@ public function providerTestConfigurePlatformEmail(): array public function providerTestConfigurePlatformEmailEnableEnv(): array { return [ - [ - 'example.com', - [ - // What's the domain name you'd like to register? - 'example.com', - // Select a Cloud Platform subscription. - '0', - // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', - // Have you finished providing the DNS records to your DNS provider? - 'y', - // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - '0', - ], - // Status code. - 0, - // Enablement response code. - '409', - // Spec key for enablement response code. - 'Already enabled', - // Expected text. - ['already enabled', "You're all set to start using Platform Email!"], - ], - [ - 'example.com', - [ + [ + 'example.com', + [ // What's the domain name you'd like to register? - 'example.com', + 'example.com', // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - '0', - ], - // Status code. - 1, - // Enablement response code. - '403', - // Spec key for enablement response code. - 'No permission', - // Expected text. - ['You do not have permission', 'Something went wrong'], - ], + '0', + ], + // Status code. + 0, + // Enablement response code. + '409', + // Spec key for enablement response code. + 'Already enabled', + // Expected text. + ['already enabled', "You're all set to start using Platform Email!"], + ], + [ + 'example.com', + [ + // What's the domain name you'd like to register? + 'example.com', + // Select a Cloud Platform subscription. + '0', + // Would you like your DNS records in BIND Zone File, JSON, or YAML format? + '0', + // Have you finished providing the DNS records to your DNS provider? + 'y', + // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. + '0', + ], + // Status code. + 1, + // Enablement response code. + '403', + // Spec key for enablement response code. + 'No permission', + // Expected text. + ['You do not have permission', 'Something went wrong'], + ], ]; } @@ -256,9 +256,9 @@ public function testConfigurePlatformEmail(mixed $baseDomain, mixed $fileDumpFor $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -305,19 +305,19 @@ public function testConfigurePlatformEmailWithMultipleAppsAndEnvs(): void { $inputs = [ // What's the domain name you'd like to register? - 'test.com', + 'test.com', // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', // What are the applications you'd like to associate this domain with? You may enter multiple separated by a comma. - '0,1', + '0,1', // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - Application 0. - '0,1', + '0,1', // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - Application 1. - '0', + '0', ]; $localMachineHelper = $this->mockLocalMachineHelper(); $mockFileSystem = $this->mockGetFilesystem($localMachineHelper); @@ -329,9 +329,9 @@ public function testConfigurePlatformEmailWithMultipleAppsAndEnvs(): void $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => 'test.com', - ], + 'form_params' => [ + 'domain' => 'test.com', + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -387,13 +387,13 @@ public function testConfigurePlatformEmailNoApps(): void $baseDomain = 'test.com'; $inputs = [ // What's the domain name you'd like to register? - $baseDomain, + $baseDomain, // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', ]; $subscriptionsResponse = $this->getMockResponseFromSpec('/subscriptions', 'get', '200'); @@ -403,9 +403,9 @@ public function testConfigurePlatformEmailNoApps(): void $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -439,13 +439,13 @@ public function testConfigurePlatformEmailWithNoDomainMatch(): void $baseDomain = 'test.com'; $inputs = [ // What's the domain name you'd like to register? - $baseDomain, + $baseDomain, // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', ]; $subscriptionsResponse = $this->getMockResponseFromSpec('/subscriptions', 'get', '200'); @@ -455,9 +455,9 @@ public function testConfigurePlatformEmailWithNoDomainMatch(): void $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -474,13 +474,13 @@ public function testConfigurePlatformEmailWithErrorRetrievingDomainHealth(): voi $baseDomain = 'test.com'; $inputs = [ // What's the domain name you'd like to register? - $baseDomain, + $baseDomain, // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '0', + '0', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', ]; $subscriptionsResponse = $this->getMockResponseFromSpec('/subscriptions', 'get', '200'); @@ -490,9 +490,9 @@ public function testConfigurePlatformEmailWithErrorRetrievingDomainHealth(): voi $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -517,15 +517,15 @@ public function testConfigurePlatformEmailJsonOutput(): void $inputs = [ // What's the domain name you'd like to register? - 'test.com', + 'test.com', // Select a Cloud Platform subscription. - '0', + '0', // Would you like your DNS records in BIND Zone File, JSON, or YAML format? - '2', + '2', // Have you finished providing the DNS records to your DNS provider? - 'y', + 'y', // What are the environments you'd like to enable email for? You may enter multiple separated by a comma. - '0', + '0', ]; $subscriptionsResponse = $this->getMockResponseFromSpec('/subscriptions', 'get', '200'); $this->clientProphecy->request('get', '/subscriptions') @@ -533,9 +533,9 @@ public function testConfigurePlatformEmailJsonOutput(): void $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => 'test.com', - ], + 'form_params' => [ + 'domain' => 'test.com', + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); @@ -585,9 +585,9 @@ public function testConfigurePlatformEmailWithAlreadyEnabledEnvs(mixed $baseDoma $postDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'post', '200'); $this->clientProphecy->request('post', "/subscriptions/{$subscriptionsResponse->_embedded->items[0]->uuid}/domains", [ - 'form_params' => [ - 'domain' => $baseDomain, - ], + 'form_params' => [ + 'domain' => $baseDomain, + ], ])->willReturn($postDomainsResponse); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); diff --git a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php index 0214457a6..8540928e9 100644 --- a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php +++ b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php @@ -30,7 +30,7 @@ public function testEmailInfoForSubscription(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -82,7 +82,7 @@ public function testEmailInfoForSubscriptionNoApps(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -100,9 +100,9 @@ public function testEmailInfoForSubscriptionWith101Apps(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, // Do you wish to continue? - 'no', + 'no', ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -134,7 +134,7 @@ public function testEmailInfoForSubscriptionNoDomains(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -149,7 +149,7 @@ public function testEmailInfoForSubscriptionNoAppDomains(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -171,7 +171,7 @@ public function testEmailInfoForSubscriptionNoSubscriptions(): void { $inputs = [ // Select a Cloud Platform subscription. - 0, + 0, ]; $this->clientProphecy->request('get', '/subscriptions') ->willReturn([]) diff --git a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php index 89dc4ab63..2e644a169 100644 --- a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php @@ -36,14 +36,14 @@ public function testCreateCert(): void '202' ); $options = [ - 'json' => [ - 'ca_certificates' => null, - 'certificate' => $certContents, - 'csr_id' => $csrId, - 'label' => $label, - 'legacy' => false, - 'private_key' => $keyContents, - ], + 'json' => [ + 'ca_certificates' => null, + 'certificate' => $certContents, + 'csr_id' => $csrId, + 'label' => $label, + 'legacy' => false, + 'private_key' => $keyContents, + ], ]; $this->clientProphecy->request('post', "/environments/{$environments[1]->id}/ssl/certificates", $options) ->willReturn($sslResponse->{'Site is being imported'}->value) @@ -52,20 +52,20 @@ public function testCreateCert(): void $this->executeCommand( [ - '--csr-id' => $csrId, - '--label' => $label, - '--legacy' => false, - 'certificate' => $certName, - 'private-key' => $keyName, + '--csr-id' => $csrId, + '--label' => $label, + '--legacy' => false, + 'certificate' => $certName, + 'private-key' => $keyName, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. - 'n', + 'n', // Select a Cloud Platform application: [Sample application 1]: - 0, - 'n', - 1, - '', + 0, + 'n', + 1, + '', ] ); } @@ -96,14 +96,14 @@ public function testCreateCertNode(): void '202' ); $options = [ - 'json' => [ - 'ca_certificates' => null, - 'certificate' => $certContents, - 'csr_id' => $csrId, - 'label' => $label, - 'legacy' => false, - 'private_key' => $keyContents, - ], + 'json' => [ + 'ca_certificates' => null, + 'certificate' => $certContents, + 'csr_id' => $csrId, + 'label' => $label, + 'legacy' => false, + 'private_key' => $keyContents, + ], ]; $this->clientProphecy->request('post', "/environments/{$environments[0]->id}/ssl/certificates", $options) ->willReturn($sslResponse->{'Site is being imported'}->value) @@ -112,17 +112,17 @@ public function testCreateCertNode(): void $this->executeCommand( [ - '--csr-id' => $csrId, - '--label' => $label, - '--legacy' => false, - 'certificate' => $certName, - 'private-key' => $keyName, + '--csr-id' => $csrId, + '--label' => $label, + '--legacy' => false, + 'certificate' => $certName, + 'private-key' => $keyName, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. - 'n', + 'n', // Select a Cloud Platform application: [Sample application 1]: - 0, + 0, ] ); } diff --git a/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php index 6bee7ed66..4f36f6d06 100644 --- a/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php @@ -44,11 +44,11 @@ public function testCopyCronTasksCommandTest(): void $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $this->executeCommand( [ - 'dest_env' => $dest, - 'source_env' => $source, + 'dest_env' => $dest, + 'source_env' => $source, ], [ - 'y', + 'y', ] ); @@ -63,8 +63,8 @@ public function testCopyCronTasksCommandTest(): void public function testCopyCronTasksCommandTestFail(): void { $this->executeCommand([ - 'dest_env' => 'app.test', - 'source_env' => 'app.test', + 'dest_env' => 'app.test', + 'source_env' => 'app.test', ],); $output = $this->getDisplay(); $this->assertStringContainsString('The source and destination environments can not be same', $output); @@ -87,11 +87,11 @@ public function testNoCronJobOnSource(): void $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $this->executeCommand( [ - 'dest_env' => $dest, - 'source_env' => $source, + 'dest_env' => $dest, + 'source_env' => $source, ], [ - 'y', + 'y', ] ); @@ -125,11 +125,11 @@ public function testExceptionOnCronJobCopy(): void $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $this->executeCommand( [ - 'dest_env' => $dest, - 'source_env' => $source, + 'dest_env' => $dest, + 'source_env' => $source, ], [ - 'y', + 'y', ] ); diff --git a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php index f7e3cdd87..d7fc310f4 100644 --- a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php @@ -94,11 +94,11 @@ public function providerTestCreateCde(): array $branch = $this->getBranch(); return [ // No args, only interactive input. - [[null, null], ['n', 0, 0]], + [[null, null], ['n', 0, 0]], // Branch as arg. - [[$branch, null], ['n', 0]], + [[$branch, null], ['n', 0]], // Branch and app id as args. - [[$branch, $application], []], + [[$branch, $application], []], ]; } @@ -112,9 +112,9 @@ public function testCreateCde(mixed $args, mixed $input): void $this->executeCommand( [ - 'applicationUuid' => $args[1], - 'branch' => $args[0], - 'label' => self::$validLabel, + 'applicationUuid' => $args[1], + 'branch' => $args[0], + 'label' => self::$validLabel, ], $input ); @@ -136,9 +136,9 @@ public function testCreateCdeNonUniqueLabel(): void $this->expectExceptionMessage('An environment named Dev already exists.'); $this->executeCommand( [ - 'applicationUuid' => $this->getApplication(), - 'branch' => $this->getBranch(), - 'label' => $label, + 'applicationUuid' => $this->getApplication(), + 'branch' => $this->getBranch(), + 'label' => $label, ] ); } @@ -154,9 +154,9 @@ public function testCreateCdeInvalidTag(): void $this->expectExceptionMessage('There is no branch or tag with the name bogus on the remote VCS.'); $this->executeCommand( [ - 'applicationUuid' => $this->getApplication(), - 'branch' => 'bogus', - 'label' => self::$validLabel, + 'applicationUuid' => $this->getApplication(), + 'branch' => 'bogus', + 'label' => self::$validLabel, ] ); } diff --git a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php index b51c46d0b..2bb6a0aa3 100644 --- a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php @@ -27,8 +27,8 @@ public function providerTestDeleteCde(): array $environmentResponse = $this->getMockEnvironmentsResponse(); $environment = $environmentResponse->_embedded->items[0]; return [ - [$environment->id], - [null], + [$environment->id], + [null], ]; } @@ -76,13 +76,13 @@ public function testDeleteCde(mixed $environmentId): void $this->executeCommand( [ - 'environmentId' => $environmentId, + 'environmentId' => $environmentId, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. - 'n', + 'n', // Select a Cloud Platform application: [Sample application 1]: - 0, + 0, ] ); $output = $this->getDisplay(); @@ -106,9 +106,9 @@ public function testNoExistingCDEEnvironment(): void [], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. - 'n', + 'n', // Select a Cloud Platform application: [Sample application 1]: - 0, + 0, ] ); } @@ -145,9 +145,9 @@ public function testNoEnvironmentArgumentPassed(): void [], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. - 'n', + 'n', // Select a Cloud Platform application: [Sample application 1]: - 0, + 0, ] ); diff --git a/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php b/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php index 4577e7d8e..975ccd8f7 100644 --- a/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php @@ -30,9 +30,9 @@ public function testEnvironmentMirror(): void 'post', "/environments/{$environmentResponse->id}/code/actions/switch", [ - 'form_params' => [ - 'branch' => $environmentResponse->vcs->path, - ], + 'form_params' => [ + 'branch' => $environmentResponse->vcs->path, + ], ] ) ->willReturn($response) @@ -51,10 +51,10 @@ public function testEnvironmentMirror(): void $this->mockNotificationResponseFromObject($response); $response->links = $response->{'_links'}; $this->clientProphecy->request('post', "/environments/{$environmentResponse->id}/databases", [ - 'json' => [ - 'name' => $databasesResponse->_embedded->items[0]->name, - 'source' => $environmentResponse->id, - ], + 'json' => [ + 'name' => $databasesResponse->_embedded->items[0]->name, + 'source' => $environmentResponse->id, + ], ]) ->willReturn($response) ->shouldBeCalled(); @@ -64,9 +64,9 @@ public function testEnvironmentMirror(): void $this->mockNotificationResponseFromObject($response); $response->links = $response->{'_links'}; $this->clientProphecy->request('post', "/environments/{$environmentResponse->id}/files", [ - 'json' => [ - 'source' => $environmentResponse->id, - ], + 'json' => [ + 'source' => $environmentResponse->id, + ], ]) ->willReturn($response) ->shouldBeCalled(); @@ -79,12 +79,12 @@ public function testEnvironmentMirror(): void $this->executeCommand( [ - 'destination-environment' => $environmentResponse->id, - 'source-environment' => $environmentResponse->id, + 'destination-environment' => $environmentResponse->id, + 'source-environment' => $environmentResponse->id, ], [ // Are you sure that you want to overwrite everything ... - 'y', + 'y', ] ); diff --git a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php index df555137e..34834f783 100644 --- a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php @@ -62,11 +62,11 @@ public function testCreate(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? // Would you like to link the project at ... ? - 'n', - 0, - self::$INPUT_DEFAULT_CHOICE, + 'n', + 0, + self::$INPUT_DEFAULT_CHOICE, // Enter a label for your Cloud IDE: - 'Example IDE', + 'Example IDE', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php index 59c186bd1..0dcc9ca30 100644 --- a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php @@ -23,7 +23,7 @@ public function setUp(OutputInterface $output = null): void parent::setUp(); $this->getCommandTester(); $this->application->addCommands([ - $this->injectCommand(SshKeyDeleteCommand::class), + $this->injectCommand(SshKeyDeleteCommand::class), ]); } @@ -44,15 +44,15 @@ public function testIdeDeleteCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application for which you'd like to create a new IDE. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select the IDE you'd like to delete: - 0, + 0, // Are you sure you want to delete ExampleIDE? - 'y', + 'y', ]; $this->executeCommand([], $inputs); @@ -72,7 +72,7 @@ public function testIdeDeleteByUuid(): void $inputs = [ // Would you like to delete the SSH key associated with this IDE from your Cloud Platform account? - 'y', + 'y', ]; $this->executeCommand(['--uuid' => IdeHelper::$remoteIdeUuid], $inputs); @@ -89,15 +89,15 @@ public function testIdeDeleteNeverMind(): void $this->mockRequest('getApplicationIdes', $applications[0]->uuid); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application for which you'd like to create a new IDE. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select the IDE you'd like to delete: - 0, + 0, // Are you sure you want to delete ExampleIDE? - 'n', + 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeHelper.php b/tests/phpunit/src/Commands/Ide/IdeHelper.php index f5f9773a7..41aa6423b 100644 --- a/tests/phpunit/src/Commands/Ide/IdeHelper.php +++ b/tests/phpunit/src/Commands/Ide/IdeHelper.php @@ -27,10 +27,10 @@ public static function unsetCloudIdeEnvVars(): void public static function getEnvVars(): array { return [ - 'ACQUIA_USER_UUID' => '4acf8956-45df-3cf4-5106-065b62cf1ac8', - 'AH_SITE_ENVIRONMENT' => 'IDE', - 'REMOTEIDE_LABEL' => self::$remoteIdeLabel, - 'REMOTEIDE_UUID' => self::$remoteIdeUuid, + 'ACQUIA_USER_UUID' => '4acf8956-45df-3cf4-5106-065b62cf1ac8', + 'AH_SITE_ENVIRONMENT' => 'IDE', + 'REMOTEIDE_LABEL' => self::$remoteIdeLabel, + 'REMOTEIDE_UUID' => self::$remoteIdeUuid, ]; } } diff --git a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php index 6fca529b1..6f9ba1f89 100644 --- a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php @@ -29,13 +29,13 @@ public function testIdeInfoCommand(): void $this->mockRequest('getIde', $ides[0]->uuid); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select an IDE ... - 0, + 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php index 4aebefff6..a9a658167 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php @@ -34,11 +34,11 @@ public function testIdeListMineCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php index 9e975cb3b..95b9475c4 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php @@ -28,11 +28,11 @@ public function testIdeListCommand(): void $this->mockRequest('getApplicationIdes', $application->uuid); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'y', + 'y', ]; $this->executeCommand([], $inputs); @@ -65,11 +65,11 @@ public function testIdeListEmptyCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select the application. - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'y', + 'y', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php index fdad33d2c..2864d1f1d 100644 --- a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php @@ -32,13 +32,13 @@ public function testIdeOpenCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Select the IDE you'd like to open: - 0, + 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php index e9f258b3b..30439e738 100644 --- a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php @@ -32,9 +32,9 @@ protected function createCommand(): CommandBase public function providerTestIdePhpVersionCommand(): array { return [ - ['7.4'], - ['8.0'], - ['8.1'], + ['7.4'], + ['8.0'], + ['8.1'], ]; } @@ -55,7 +55,7 @@ public function testIdePhpVersionCommand(string $version): void $this->command->setPhpVersionFilePath($phpVersionFilePath); $this->command->setIdePhpFilePathPrefix($phpFilepathPrefix); $this->executeCommand([ - 'version' => $version, + 'version' => $version, ], []); } @@ -65,10 +65,10 @@ public function testIdePhpVersionCommand(string $version): void public function providerTestIdePhpVersionCommandFailure(): array { return [ - ['6.3', AcquiaCliException::class], - ['6', ValidatorException::class], - ['7', ValidatorException::class], - ['7.', ValidatorException::class], + ['6.3', AcquiaCliException::class], + ['6', ValidatorException::class], + ['7', ValidatorException::class], + ['7.', ValidatorException::class], ]; } @@ -79,7 +79,7 @@ public function testIdePhpVersionCommandFailure(string $version, string $excepti { $this->expectException($exceptionClass); $this->executeCommand([ - 'version' => $version, + 'version' => $version, ]); } @@ -89,7 +89,7 @@ public function testIdePhpVersionCommandOutsideIde(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('This command can only be run inside of an Acquia Cloud IDE'); $this->executeCommand([ - 'version' => '7.3', + 'version' => '7.3', ]); } @@ -99,9 +99,9 @@ protected function mockRestartPhp(ObjectProphecy|LocalMachineHelper $localMachin $process->isSuccessful()->willReturn(true); $process->getExitCode()->willReturn(0); $localMachineHelper->execute([ - 'supervisorctl', - 'restart', - 'php-fpm', + 'supervisorctl', + 'restart', + 'php-fpm', ], null, null, false)->willReturn($process->reveal())->shouldBeCalled(); return $process; } diff --git a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php index 89da557cb..83363d27b 100644 --- a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php @@ -30,9 +30,9 @@ public function setUpXdebug(string $phpVersion): void $localMachineHelper = $this->mockLocalMachineHelper(); $localMachineHelper ->execute([ - 'supervisorctl', - 'restart', - 'php-fpm', + 'supervisorctl', + 'restart', + 'php-fpm', ], null, null, false) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -49,9 +49,9 @@ protected function createCommand(): CommandBase public function providerTestXdebugCommandEnable(): array { return [ - ['7.4'], - ['8.0'], - ['8.1'], + ['7.4'], + ['8.0'], + ['8.1'], ]; } diff --git a/tests/phpunit/src/Commands/InferApplicationTest.php b/tests/phpunit/src/Commands/InferApplicationTest.php index 0743818e8..afb39f52b 100644 --- a/tests/phpunit/src/Commands/InferApplicationTest.php +++ b/tests/phpunit/src/Commands/InferApplicationTest.php @@ -41,9 +41,9 @@ public function testInfer(): void $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'y', + 'y', // Would you like to link the project at ... - 'y', + 'y', ]); $output = $this->getDisplay(); @@ -76,11 +76,11 @@ public function testInferFailure(): void $this->executeCommand([], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'y', + 'y', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... - 'y', + 'y', ]); $output = $this->getDisplay(); @@ -95,7 +95,7 @@ public function testInferInvalidGitConfig(): void { $this->expectException(AcquiaCliException::class); $this->executeCommand([], [ - 'y', + 'y', ]); } } diff --git a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php index 2726ccf6d..fb396a67a 100644 --- a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php @@ -57,17 +57,17 @@ public function testCloneRepo(): void $inputs = [ // Would you like to clone a project into the current directory? - 'y', + 'y', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([ - '--dir' => $dir, - '--no-scripts' => true, + '--dir' => $dir, + '--no-scripts' => true, ], $inputs); } @@ -86,7 +86,7 @@ public function testPullCode(): void $this->mockExecuteGitStatus(false, $localMachineHelper, $this->projectDir); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], self::inputChooseEnvironment()); $output = $this->getDisplay(); @@ -220,9 +220,9 @@ public function testWithVendorDir(): void public function providerTestMatchPhpVersion(): array { return [ - ['7.1'], - ['7.2'], - [''], + ['7.1'], + ['7.2'], + [''], ]; } @@ -233,7 +233,7 @@ public function testMatchPhpVersion(string $phpVersion): void { IdeHelper::setCloudIdeEnvVars(); $this->application->addCommands([ - $this->injectCommand(IdePhpVersionCommand::class), + $this->injectCommand(IdePhpVersionCommand::class), ]); $this->command = $this->createCommand(); $dir = '/home/ide/project'; @@ -260,15 +260,15 @@ public function testMatchPhpVersion(string $phpVersion): void ->shouldBeCalled(); $this->executeCommand([ - '--dir' => $dir, - '--no-scripts' => true, + '--dir' => $dir, + '--no-scripts' => true, // @todo Execute ONLY match php aspect, not the code pull. - 'environmentId' => $environmentResponse->id, + 'environmentId' => $environmentResponse->id, ], [ // Choose an Acquia environment: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to change the PHP version on this IDE to match the PHP version on ... ? - 'n', + 'n', ]); $output = $this->getDisplay(); @@ -288,10 +288,10 @@ protected function mockExecuteGitClone( mixed $dir ): void { $command = [ - 'git', - 'clone', - $environmentsResponse->vcs->url, - $dir, + 'git', + 'clone', + $environmentsResponse->vcs->url, + $dir, ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true, null, ['GIT_SSH_COMMAND' => 'ssh -o StrictHostKeyChecking=no']) ->willReturn($process->reveal()) diff --git a/tests/phpunit/src/Commands/Pull/PullCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCommandTest.php index cf04096d1..7e22962c7 100644 --- a/tests/phpunit/src/Commands/Pull/PullCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCommandTest.php @@ -67,17 +67,17 @@ public function testPull(): void ->shouldBeCalled(); $this->mockExecuteMySqlImport($localMachineHelper, true, true, 'my_db', 'my_dbdev', 'drupal'); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - self::$INPUT_DEFAULT_CHOICE, - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, ]); $output = $this->getDisplay(); @@ -101,7 +101,7 @@ public function testMissingLocalRepo(): void $this->expectExceptionMessage('Execute this command from within a Drupal project directory or an empty directory'); $inputs = [ // Would you like to clone a project into the current directory? - 'n', + 'n', ]; $this->executeCommand([], $inputs); } diff --git a/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php b/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php index 5a38c923c..0dc9022f6 100644 --- a/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php +++ b/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php @@ -57,11 +57,11 @@ protected function mockExecuteDrushStatus( ->willReturn(json_encode(['db-status' => 'Connected'])); $localMachineHelper ->execute([ - 'drush', - 'status', - '--fields=db-status,drush-version', - '--format=json', - '--no-interaction', + 'drush', + 'status', + '--fields=db-status,drush-version', + '--format=json', + '--no-interaction', ], Argument::any(), $dir, false) ->willReturn($drushStatusProcess->reveal()) ->shouldBeCalled(); @@ -73,11 +73,11 @@ protected function mockExecuteDrushCacheRebuild( ): void { $localMachineHelper ->execute([ - 'drush', - 'cache:rebuild', - '--yes', - '--no-interaction', - '--verbose', + 'drush', + 'cache:rebuild', + '--yes', + '--no-interaction', + '--verbose', ], Argument::type('callable'), $this->projectDir, false) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -89,11 +89,11 @@ protected function mockExecuteDrushSqlSanitize( ): void { $localMachineHelper ->execute([ - 'drush', - 'sql:sanitize', - '--yes', - '--no-interaction', - '--verbose', + 'drush', + 'sql:sanitize', + '--yes', + '--no-interaction', + '--verbose', ], Argument::type('callable'), $this->projectDir, false) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -114,9 +114,9 @@ protected function mockExecuteComposerInstall( ): void { $localMachineHelper ->execute([ - 'composer', - 'install', - '--no-interaction', + 'composer', + 'install', + '--no-interaction', ], Argument::type('callable'), $this->projectDir, false, null) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -127,7 +127,7 @@ protected function mockDrupalSettingsRefresh( ): void { $localMachineHelper ->execute([ - '/ide/drupal-setup.sh', + '/ide/drupal-setup.sh', ]); } @@ -150,9 +150,9 @@ protected function mockGetLocalCommitHash( $process->isSuccessful()->willReturn(true)->shouldBeCalled(); $process->getOutput()->willReturn($commitHash)->shouldBeCalled(); $localMachineHelper->execute([ - 'git', - 'rev-parse', - 'HEAD', + 'git', + 'rev-parse', + 'HEAD', ], null, $cwd, false)->willReturn($process->reveal())->shouldBeCalled(); } @@ -181,9 +181,9 @@ protected function mockExecuteGitFetchAndCheckout( string $vcsPath ): void { $localMachineHelper->execute([ - 'git', - 'fetch', - '--all', + 'git', + 'fetch', + '--all', ], Argument::type('callable'), $cwd, false) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -193,9 +193,9 @@ protected function mockExecuteGitFetchAndCheckout( protected function mockExecuteGitCheckout(ObjectProphecy $localMachineHelper, string $vcsPath, string $cwd, ObjectProphecy $process): void { $localMachineHelper->execute([ - 'git', - 'checkout', - $vcsPath, + 'git', + 'checkout', + $vcsPath, ], Argument::type('callable'), $cwd, false) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -210,11 +210,11 @@ protected function mockExecuteRsync( $process = $this->mockProcess(); $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); $command = [ - 'rsync', - '-avPhze', - 'ssh -o StrictHostKeyChecking=no', - $environment->ssh_url . ':' . $sourceDir, - $destinationDir, + 'rsync', + '-avPhze', + 'ssh -o StrictHostKeyChecking=no', + $environment->ssh_url . ':' . $sourceDir, + $destinationDir, ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) ->willReturn($process->reveal()) @@ -229,12 +229,12 @@ protected function mockExecuteMySqlConnect( $process = $this->mockProcess($success); $localMachineHelper ->execute([ - 'mysql', - '--host', - $this->dbHost, - '--user', - 'drupal', - 'drupal', + 'mysql', + '--host', + $this->dbHost, + '--user', + 'drupal', + 'drupal', ], Argument::type('callable'), null, false, null, ['MYSQL_PWD' => 'drupal']) ->willReturn($process->reveal()) ->shouldBeCalled(); @@ -248,15 +248,15 @@ protected function mockExecuteMySqlListTables( $process = $this->mockProcess(); $process->getOutput()->willReturn('table1'); $command = [ - 'mysql', - '--host', - 'localhost', - '--user', - 'drupal', - $dbName, - '--silent', - '-e', - 'SHOW TABLES;', + 'mysql', + '--host', + 'localhost', + '--user', + 'drupal', + $dbName, + '--silent', + '-e', + 'SHOW TABLES;', ]; $localMachineHelper ->execute($command, Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) @@ -339,8 +339,8 @@ public function mockGetBackup(mixed $environment): void }; $backups = new BackupsResponse( $this->mockRequest('getEnvironmentsDatabaseBackups', [ - $environment->id, - 'my_db', + $environment->id, + 'my_db', ], null, null, $tamper) ); $this->mockDownloadBackup($databases[0], $environment, $backups[0]); @@ -370,16 +370,16 @@ protected function mockDownloadBackup(object $database, object $environment, obj $dbMachineName = 'db' . $database->id; } $filename = implode('-', [ - $environment->name, - $database->name, - $dbMachineName, - $backup->completedAt, + $environment->name, + $database->name, + $dbMachineName, + $backup->completedAt, ]) . '.sql.gz'; $localFilepath = Path::join(sys_get_temp_dir(), $filename); $this->clientProphecy->addOption('sink', $localFilepath)->shouldBeCalled(); $this->clientProphecy->addOption('curl.options', [ - 'CURLOPT_FILE' => $localFilepath, - 'CURLOPT_RETURNTRANSFER' => false, + 'CURLOPT_FILE' => $localFilepath, + 'CURLOPT_RETURNTRANSFER' => false, ])->shouldBeCalled(); $this->clientProphecy->addOption('progress', Argument::type('Closure'))->shouldBeCalled(); $this->clientProphecy->addOption('on_stats', Argument::type('Closure'))->shouldBeCalled(); diff --git a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php index 0a6ede37d..5b9705c6c 100644 --- a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php @@ -68,7 +68,7 @@ public function testPullDatabases(): void $this->mockExecuteDrushSqlSanitize($localMachineHelper, $process); $this->executeCommand([ - '--no-scripts' => false, + '--no-scripts' => false, ], self::inputChooseEnvironment()); $output = $this->getDisplay(); @@ -103,16 +103,16 @@ public function testPullProdDatabase(): void $localMachineHelper->getFilesystem()->willReturn($fs)->shouldBeCalled(); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - 1, + 1, ]); $output = $this->getDisplay(); @@ -134,7 +134,7 @@ public function testPullDatabasesLocalConnectionFailure(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to connect'); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], self::inputChooseEnvironment()); } @@ -154,7 +154,7 @@ public function testPullDatabaseNoPv(): void $fs->remove(Argument::type('string'))->shouldBeCalled(); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], self::inputChooseEnvironment()); $output = $this->getDisplay(); @@ -167,21 +167,21 @@ public function testPullMultipleDatabases(): void $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', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose a Cloud Platform environment [Dev, dev (vcs: master)]: - 0, + 0, // Choose a site [jxr5000596dev (oracletest1.dev-profserv2.acsitefactory.com)]: - 0, + 0, // Choose databases. You may choose multiple. Use commas to separate choices. [profserv2 (default)]: - '10,27', + '10,27', ]; $this->executeCommand([ - '--multiple-dbs' => true, - '--no-scripts' => true, + '--multiple-dbs' => true, + '--no-scripts' => true, ], $inputs); } @@ -191,8 +191,8 @@ public function testPullDatabasesOnDemand(): void $inputs = self::inputChooseEnvironment(); $this->executeCommand([ - '--no-scripts' => true, - '--on-demand' => true, + '--no-scripts' => true, + '--on-demand' => true, ], $inputs); $output = $this->getDisplay(); @@ -211,7 +211,7 @@ public function testPullDatabasesNoExistingBackup(): void $inputs = self::inputChooseEnvironment(); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], $inputs); $output = $this->getDisplay(); @@ -231,8 +231,8 @@ public function testPullDatabasesSiteArgument(): void $inputs = self::inputChooseEnvironment(); $this->executeCommand([ - '--no-scripts' => true, - 'site' => 'jxr5000596dev', + '--no-scripts' => true, + 'site' => 'jxr5000596dev', ], $inputs); $output = $this->getDisplay(); @@ -260,7 +260,7 @@ public function testPullDatabaseWithMySqlDropError(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to drop tables from database'); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], self::inputChooseEnvironment()); } @@ -281,7 +281,7 @@ public function testPullDatabaseWithMySqlImportError(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Unable to import local database'); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], self::inputChooseEnvironment()); } @@ -388,16 +388,16 @@ public function testPullNode(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('No compatible environments found'); $this->executeCommand([ - '--no-scripts' => true, + '--no-scripts' => true, ], [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - 1, + 1, ]); } } diff --git a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php index f1acadef2..eab9c305b 100644 --- a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php @@ -47,15 +47,15 @@ public function testRefreshAcsfFiles(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - 0, + 0, // Choose site from which to copy files: - 0, + 0, ]; $this->executeCommand([], $inputs); @@ -86,15 +86,15 @@ public function testRefreshCloudFiles(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - 0, + 0, // Choose site from which to copy files: - 0, + 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php index ccd4602a2..1e0bcaef2 100644 --- a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php @@ -36,17 +36,17 @@ public function testRefreshScripts(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose an Acquia environment: - 0, + 0, ]; $this->executeCommand([ - '--dir' => $this->projectDir, + '--dir' => $this->projectDir, ], $inputs); $this->getDisplay(); diff --git a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php index 4b2b62ded..ada794d0f 100644 --- a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php @@ -36,8 +36,8 @@ public function testNoAuthenticationRequired(): void public function providerTestPushArtifact(): array { return [ - [OutputInterface::VERBOSITY_NORMAL, false], - [OutputInterface::VERBOSITY_VERY_VERBOSE, true], + [OutputInterface::VERBOSITY_NORMAL, false], + [OutputInterface::VERBOSITY_VERY_VERBOSE, true], ]; } @@ -53,13 +53,13 @@ public function testPushArtifact(int $verbosity, bool $printOutput): void $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, true, $printOutput); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Choose an Acquia environment: - 0, + 0, ]; $this->executeCommand([], $inputs, $verbosity); @@ -101,15 +101,15 @@ public function testPushTagArtifact(): void $this->mockGitTag($localMachineHelper, $gitTag, $artifactDir); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', ]; $this->executeCommand([ - '--destination-git-tag' => $gitTag, - '--source-git-tag' => '1.2.0', + '--destination-git-tag' => $gitTag, + '--source-git-tag' => '1.2.0', ], $inputs); $output = $this->getDisplay(); @@ -126,13 +126,13 @@ public function testPushArtifactWithAcquiaCliFile(): void $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid); $this->datastoreAcli->set('push.artifact.destination-git-urls', [ - 'https://github.com/example1/cli.git', - 'https://github.com/example2/cli.git', + 'https://github.com/example1/cli.git', + 'https://github.com/example2/cli.git', ]); $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, 'master', $this->datastoreAcli->get('push.artifact.destination-git-urls')); $this->executeCommand([ - '--destination-git-branch' => 'master', + '--destination-git-branch' => 'master', ]); $output = $this->getDisplay(); @@ -147,14 +147,14 @@ public function testPushArtifactWithArgs(): void $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid); $destinationGitUrls = [ - 'https://github.com/example1/cli.git', - 'https://github.com/example2/cli.git', + 'https://github.com/example1/cli.git', + 'https://github.com/example2/cli.git', ]; $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, 'master', $destinationGitUrls); $this->executeCommand([ - '--destination-git-branch' => 'master', - '--destination-git-urls' => $destinationGitUrls, + '--destination-git-branch' => 'master', + '--destination-git-urls' => $destinationGitUrls, ]); $output = $this->getDisplay(); @@ -172,13 +172,13 @@ public function testPushArtifactNoPush(): void $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Choose an Acquia environment: - 0, + 0, ]; $this->executeCommand(['--no-push' => true], $inputs); @@ -198,13 +198,13 @@ public function testPushArtifactNoCommit(): void $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, false, false); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Choose an Acquia environment: - 0, + 0, ]; $this->executeCommand(['--no-commit' => true], $inputs); @@ -221,13 +221,13 @@ public function testPushArtifactNoClone(): void $this->setUpPushArtifact($localMachineHelper, 'nothing', [], 'something', false, false, false); $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'y', + 'y', // Choose an Acquia environment: - 0, + 0, ]; $this->executeCommand(['--no-clone' => true], $inputs); @@ -318,16 +318,16 @@ protected function mockGitAddCommit(ObjectProphecy $localMachineHelper, string $ protected function mockReadComposerJson(ObjectProphecy $localMachineHelper, string $artifactDir): void { $composerJson = json_encode([ - 'extra' => [ - 'drupal-scaffold' => [ - 'file-mapping' => [ - '[web-root]/index.php' => [], - ], - ], - 'installer-paths' => [ - 'docroot/core' => [], - ], - ], + 'extra' => [ + 'drupal-scaffold' => [ + 'file-mapping' => [ + '[web-root]/index.php' => [], + ], + ], + 'installer-paths' => [ + 'docroot/core' => [], + ], + ], ]); $localMachineHelper->readFile(Path::join($this->projectDir, 'composer.json')) ->willReturn($composerJson); @@ -348,9 +348,9 @@ protected function mockGitTag(ObjectProphecy $localMachineHelper, string $gitTag { $process = $this->mockProcess(); $localMachineHelper->execute([ - 'git', - 'tag', - $gitTag, + 'git', + 'tag', + $gitTag, ], Argument::type('callable'), $artifactDir, true) ->willReturn($process->reveal())->shouldBeCalled(); } diff --git a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php index 605dbbf70..ec295d15c 100644 --- a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php @@ -26,8 +26,8 @@ class PushDatabaseCommandTest extends CommandTestBase public function providerTestPushDatabase(): array { return [ - [OutputInterface::VERBOSITY_NORMAL, false], - [OutputInterface::VERBOSITY_VERY_VERBOSE, true], + [OutputInterface::VERBOSITY_NORMAL, false], + [OutputInterface::VERBOSITY_VERY_VERBOSE, true], ]; } @@ -75,17 +75,17 @@ public function testPushDatabase(int $verbosity, bool $printOutput): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose a Cloud Platform environment. - 0, + 0, // Choose a database. - 0, + 0, // Overwrite the profserv2 database on dev with a copy of the database from the current machine? - 'y', + 'y', ]; $this->executeCommand([], $inputs, $verbosity); @@ -109,11 +109,11 @@ protected function mockUploadDatabaseDump( ): void { $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); $command = [ - 'rsync', - '-tDvPhe', - 'ssh -o StrictHostKeyChecking=no', - sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz', - 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz', + 'rsync', + '-tDvPhe', + 'ssh -o StrictHostKeyChecking=no', + sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz', + 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, $printOutput, null) ->willReturn($process->reveal()) @@ -143,14 +143,14 @@ protected function mockGetAcsfSitesLMH(ObjectProphecy $localMachineHelper): void $multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/multisite-config.json')); $acsfMultisiteFetchProcess->getOutput()->willReturn($multisiteConfig)->shouldBeCalled(); $cmd = [ - 0 => 'ssh', - 1 => 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com', - 2 => '-t', - 3 => '-o StrictHostKeyChecking=no', - 4 => '-o AddressFamily inet', - 5 => '-o LogLevel=ERROR', - 6 => 'cat', - 7 => '/var/www/site-php/profserv2.01dev/multisite-config.json', + 0 => 'ssh', + 1 => 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com', + 2 => '-t', + 3 => '-o StrictHostKeyChecking=no', + 4 => '-o AddressFamily inet', + 5 => '-o LogLevel=ERROR', + 6 => 'cat', + 7 => '/var/www/site-php/profserv2.01dev/multisite-config.json', ]; $localMachineHelper->execute($cmd, Argument::type('callable'), null, false, null)->willReturn($acsfMultisiteFetchProcess->reveal())->shouldBeCalled(); } @@ -158,13 +158,13 @@ protected function mockGetAcsfSitesLMH(ObjectProphecy $localMachineHelper): void private function mockImportDatabaseDumpOnRemote(ObjectProphecy|LocalMachineHelper $localMachineHelper, Process|ObjectProphecy $process, bool $printOutput = true): void { $cmd = [ - 0 => 'ssh', - 1 => 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com', - 2 => '-t', - 3 => '-o StrictHostKeyChecking=no', - 4 => '-o AddressFamily inet', - 5 => '-o LogLevel=ERROR', - 6 => 'pv /mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz --bytes --rate | gunzip | MYSQL_PWD=password mysql --host=fsdb-74.enterprise-g1.hosting.acquia.com.enterprise-g1.hosting.acquia.com --user=s164 profserv2db14390', + 0 => 'ssh', + 1 => 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com', + 2 => '-t', + 3 => '-o StrictHostKeyChecking=no', + 4 => '-o AddressFamily inet', + 5 => '-o LogLevel=ERROR', + 6 => 'pv /mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz --bytes --rate | gunzip | MYSQL_PWD=password mysql --host=fsdb-74.enterprise-g1.hosting.acquia.com.enterprise-g1.hosting.acquia.com --user=s164 profserv2db14390', ]; $localMachineHelper->execute($cmd, Argument::type('callable'), null, $printOutput, null) ->willReturn($process->reveal()) diff --git a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php index 6bb9e5d34..f238e8f8a 100644 --- a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php @@ -32,17 +32,17 @@ public function testPushFilesAcsf(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose a Cloud Platform environment. - 0, + 0, // Choose a site. - 0, + 0, // Overwrite the public files directory. - 'y', + 'y', ]; $this->executeCommand([], $inputs); @@ -71,17 +71,17 @@ public function testPushFilesCloud(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose a Cloud Platform environment. - 0, + 0, // Choose a site. - 0, + 0, // Overwrite the public files directory. - 'y', + 'y', ]; $this->executeCommand([], $inputs); @@ -108,17 +108,17 @@ public function testPushFilesNoOverwrite(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - 0, + 0, // Would you like to link the project at ... ? - 'n', + 'n', // Choose a Cloud Platform environment. - 0, + 0, // Choose a site. - 0, + 0, // Overwrite the public files directory. - 'n', + 'n', ]; $this->executeCommand([], $inputs); @@ -141,11 +141,11 @@ protected function mockExecuteCloudRsync( $parts = explode('.', $environment->ssh_url); $sitegroup = reset($parts); $command = [ - 'rsync', - '-avPhze', - 'ssh -o StrictHostKeyChecking=no', - $this->projectDir . '/docroot/sites/bar/files/', - $environment->ssh_url . ':/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/bar/files', + 'rsync', + '-avPhze', + 'ssh -o StrictHostKeyChecking=no', + $this->projectDir . '/docroot/sites/bar/files/', + $environment->ssh_url . ':/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/bar/files', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) ->willReturn($process->reveal()) @@ -159,11 +159,11 @@ protected function mockExecuteAcsfRsync( ): void { $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); $command = [ - 'rsync', - '-avPhze', - 'ssh -o StrictHostKeyChecking=no', - $this->projectDir . '/docroot/sites/' . $site . '/files/', - 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/files/profserv2.01dev/sites/g/files/' . $site . '/files', + 'rsync', + '-avPhze', + 'ssh -o StrictHostKeyChecking=no', + $this->projectDir . '/docroot/sites/' . $site . '/files/', + 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/files/profserv2.01dev/sites/g/files/' . $site . '/files', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) ->willReturn($process->reveal()) diff --git a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php index 62c479b2f..ffccdb5cc 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php @@ -38,10 +38,10 @@ public function setUp(): void public function providerTestRemoteAliasesDownloadCommand(): array { return [ - [['9'], []], - [['9'], ['--destination-dir' => 'testdir'], 'testdir'], - [['9'], ['--all' => true], null, true], - [['8'], []], + [['9'], []], + [['9'], ['--destination-dir' => 'testdir'], 'testdir'], + [['9'], ['--all' => true], null, true], + [['8'], []], ]; } diff --git a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php index 41fd60534..79358c209 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php @@ -26,11 +26,11 @@ public function testRemoteAliasesListCommand(): void $inputs = [ // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - 'n', + 'n', // Select a Cloud Platform application: - '0', + '0', // Would you like to link the project at ... - 'n', + 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php index 8eeef3751..7e7614525 100644 --- a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php @@ -25,18 +25,18 @@ protected function createCommand(): CommandBase public function providerTestRemoteDrushCommand(): array { return [ - [ - [ - '-vvv' => '', - 'drush_command' => 'status --fields=db-status', - ], - ], - [ - [ - '-vvv' => '', - 'drush_command' => 'status --fields=db-status', - ], - ], + [ + [ + '-vvv' => '', + 'drush_command' => 'status --fields=db-status', + ], + ], + [ + [ + '-vvv' => '', + 'drush_command' => 'status --fields=db-status', + ], + ], ]; } @@ -50,15 +50,15 @@ public function testRemoteDrushCommand(array $args): void [$process, $localMachineHelper] = $this->mockForExecuteCommand(); $localMachineHelper->checkRequiredBinariesExist(['ssh'])->shouldBeCalled(); $sshCommand = [ - 'ssh', - 'site.dev@sitedev.ssh.hosted.acquia-sites.com', - '-t', - '-o StrictHostKeyChecking=no', - '-o AddressFamily inet', - '-o LogLevel=ERROR', - 'cd /var/www/html/site.dev/docroot; ', - 'drush', - '--uri=http://sitedev.hosted.acquia-sites.com status --fields=db-status', + 'ssh', + 'site.dev@sitedev.ssh.hosted.acquia-sites.com', + '-t', + '-o StrictHostKeyChecking=no', + '-o AddressFamily inet', + '-o LogLevel=ERROR', + 'cd /var/www/html/site.dev/docroot; ', + 'drush', + '--uri=http://sitedev.hosted.acquia-sites.com status --fields=db-status', ]; $localMachineHelper ->execute($sshCommand, Argument::type('callable'), null, true, null) diff --git a/tests/phpunit/src/Commands/Remote/SshCommandTest.php b/tests/phpunit/src/Commands/Remote/SshCommandTest.php index 6d21e03ec..a6c50048b 100644 --- a/tests/phpunit/src/Commands/Remote/SshCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/SshCommandTest.php @@ -30,13 +30,13 @@ public function testRemoteAliasesDownloadCommand(): void [$process, $localMachineHelper] = $this->mockForExecuteCommand(); $localMachineHelper->checkRequiredBinariesExist(['ssh'])->shouldBeCalled(); $sshCommand = [ - 'ssh', - 'site.dev@sitedev.ssh.hosted.acquia-sites.com', - '-t', - '-o StrictHostKeyChecking=no', - '-o AddressFamily inet', - '-o LogLevel=ERROR', - 'cd /var/www/html/devcloud2.dev; exec $SHELL -l', + 'ssh', + 'site.dev@sitedev.ssh.hosted.acquia-sites.com', + '-t', + '-o StrictHostKeyChecking=no', + '-o AddressFamily inet', + '-o LogLevel=ERROR', + 'cd /var/www/html/devcloud2.dev; exec $SHELL -l', ]; $localMachineHelper ->execute($sshCommand, Argument::type('callable'), null, true, null) @@ -46,7 +46,7 @@ public function testRemoteAliasesDownloadCommand(): void $this->command->sshHelper = new SshHelper($this->output, $localMachineHelper->reveal(), $this->logger); $args = [ - 'alias' => 'devcloud2.dev', + 'alias' => 'devcloud2.dev', ]; $this->executeCommand($args); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php index 8c856d7a4..b4536da83 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php @@ -28,40 +28,40 @@ protected function createCommand(): CommandBase public function providerTestCreate(): array { return [ - [ - true, + [ + true, // Args. - [ - '--filename' => $this->filename, - '--password' => 'acli123', - ], - // Inputs. - [], - ], - [ - true, - // Args. - [], - // Inputs. - [ - // Enter a filename for your new local SSH key: - $this->filename, - // Enter a password for your SSH key: - 'acli123', - ], - ], - [ - false, - // Args. - [], - // Inputs. - [ - // Enter a filename for your new local SSH key: - $this->filename, - // Enter a password for your SSH key: - 'acli123', - ], - ], + [ + '--filename' => $this->filename, + '--password' => 'acli123', + ], + // Inputs. + [], + ], + [ + true, + // Args. + [], + // Inputs. + [ + // Enter a filename for your new local SSH key: + $this->filename, + // Enter a password for your SSH key: + 'acli123', + ], + ], + [ + false, + // Args. + [], + // Inputs. + [ + // Enter a filename for your new local SSH key: + $this->filename, + // Enter a password for your SSH key: + 'acli123', + ], + ], ]; } diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php index 8c11bf4c8..14f6aa555 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php @@ -22,8 +22,8 @@ public function setUp(mixed $output = null): void $this->getCommandTester(); $this->application->addCommands([ - $this->injectCommand(SshKeyCreateCommand::class), - $this->injectCommand(SshKeyUploadCommand::class), + $this->injectCommand(SshKeyCreateCommand::class), + $this->injectCommand(SshKeyUploadCommand::class), ]); } @@ -45,10 +45,10 @@ public function testCreateUpload(): void $this->mockGenerateSshKey($localMachineHelper, $mockRequestArgs['public_key']); $body = [ - 'json' => [ - 'label' => $mockRequestArgs['label'], - 'public_key' => $mockRequestArgs['public_key'], - ], + 'json' => [ + 'label' => $mockRequestArgs['label'], + 'public_key' => $mockRequestArgs['public_key'], + ], ]; $this->mockRequest('postAccountSshKeys', null, $body); $this->mockGetLocalSshKey($localMachineHelper, $fileSystem, $mockRequestArgs['public_key']); @@ -64,11 +64,11 @@ public function testCreateUpload(): void $inputs = [ // Enter a filename for your new local SSH key: - $sshKeyFilename, + $sshKeyFilename, // Enter a password for your SSH key: - 'acli123', + 'acli123', // Label. - $mockRequestArgs['label'], + $mockRequestArgs['label'], ]; $this->executeCommand(['--no-wait' => ''], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php index 7df5b9621..7be735fd0 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php @@ -25,9 +25,9 @@ public function testDelete(): void $inputs = [ // Choose key. - self::$INPUT_DEFAULT_CHOICE, + self::$INPUT_DEFAULT_CHOICE, // Do you also want to delete the corresponding local key files? - 'n', + 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php index 5f8fcf7eb..1289da0c9 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php @@ -28,7 +28,7 @@ public function testInfo(): void $inputs = [ // Choose key. - '0', + '0', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php index 7c8726054..4a2f25d22 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php @@ -26,39 +26,39 @@ public function providerTestUpload(): array { $sshKeysRequestBody = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); return [ - [ + [ // Args. - [], + [], // Inputs. - [ + [ // Choose key. - '0', + '0', // Enter a Cloud Platform label for this SSH key: - $sshKeysRequestBody['label'], + $sshKeysRequestBody['label'], // Would you like to wait until Cloud Platform is ready? (yes/no) - 'y', + 'y', // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) - 'n', - ], - // Perms. - true, - ], - [ - // Args. - [ - '--filepath' => 'id_rsa.pub', - '--label' => $sshKeysRequestBody['label'], - ], - // Inputs. - [ - // Would you like to wait until Cloud Platform is ready? (yes/no) - 'y', - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) - 'n', - ], - // Perms. - false, - ], + 'n', + ], + // Perms. + true, + ], + [ + // Args. + [ + '--filepath' => 'id_rsa.pub', + '--label' => $sshKeysRequestBody['label'], + ], + // Inputs. + [ + // Would you like to wait until Cloud Platform is ready? (yes/no) + 'y', + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) + 'n', + ], + // Perms. + false, + ], ]; } @@ -69,10 +69,10 @@ public function testUpload(array $args, array $inputs, bool $perms): void { $sshKeysRequestBody = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $body = [ - 'json' => [ - 'label' => $sshKeysRequestBody['label'], - 'public_key' => $sshKeysRequestBody['public_key'], - ], + 'json' => [ + 'label' => $sshKeysRequestBody['label'], + 'public_key' => $sshKeysRequestBody['public_key'], + ], ]; $this->mockRequest('postAccountSshKeys', null, $body); $this->mockListSshKeyRequestWithUploadedKey($sshKeysRequestBody); @@ -111,10 +111,10 @@ public function testUploadNode(): void { $sshKeysRequestBody = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $body = [ - 'json' => [ - 'label' => $sshKeysRequestBody['label'], - 'public_key' => $sshKeysRequestBody['public_key'], - ], + 'json' => [ + 'label' => $sshKeysRequestBody['label'], + 'public_key' => $sshKeysRequestBody['public_key'], + ], ]; $this->mockRequest('postAccountSshKeys', null, $body); $this->mockListSshKeyRequestWithUploadedKey($sshKeysRequestBody); @@ -144,13 +144,13 @@ public function testUploadNode(): void // Choose a local SSH key to upload to the Cloud Platform. $inputs = [ // Choose key. - '0', + '0', // Enter a Cloud Platform label for this SSH key: - $sshKeysRequestBody['label'], + $sshKeysRequestBody['label'], // Would you like to wait until Cloud Platform is ready? (yes/no) - 'y', + 'y', // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) - 'n', + 'n', ]; $this->executeCommand([], $inputs); @@ -165,9 +165,9 @@ public function testInvalidFilepath(): void { $inputs = [ // Choose key. - '0', + '0', // Label. - 'Test', + 'Test', ]; $filepath = Path::join(sys_get_temp_dir(), 'notarealfile'); $args = ['--filepath' => $filepath]; diff --git a/tests/phpunit/src/Commands/TelemetryCommandTest.php b/tests/phpunit/src/Commands/TelemetryCommandTest.php index 3b94f8fe4..6df390c61 100644 --- a/tests/phpunit/src/Commands/TelemetryCommandTest.php +++ b/tests/phpunit/src/Commands/TelemetryCommandTest.php @@ -52,11 +52,11 @@ public function testTelemetryCommand(): void 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.', - ], + ['n'], + 'Ok, no data will be collected and shared with us.', + ], ]; } diff --git a/tests/phpunit/src/Commands/WizardTestBase.php b/tests/phpunit/src/Commands/WizardTestBase.php index 63f39ecd8..34cab7360 100644 --- a/tests/phpunit/src/Commands/WizardTestBase.php +++ b/tests/phpunit/src/Commands/WizardTestBase.php @@ -29,9 +29,9 @@ public function setUp(): void parent::setUp(); $this->getCommandTester(); $this->application->addCommands([ - $this->injectCommand(SshKeyCreateCommand::class), - $this->injectCommand(SshKeyDeleteCommand::class), - $this->injectCommand(SshKeyUploadCommand::class), + $this->injectCommand(SshKeyCreateCommand::class), + $this->injectCommand(SshKeyDeleteCommand::class), + $this->injectCommand(SshKeyUploadCommand::class), ]); } @@ -47,7 +47,7 @@ protected function tearDown(): void public static function getEnvVars(): array { return [ - 'ACQUIA_APPLICATION_UUID' => self::$applicationUuid, + 'ACQUIA_APPLICATION_UUID' => self::$applicationUuid, ]; } @@ -58,10 +58,10 @@ protected function runTestCreate(): void $request = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $body = [ - 'json' => [ - 'label' => 'IDE_ExampleIDE_215824ff272a4a8c9027df32ed1d68a9', - 'public_key' => $request['public_key'], - ], + 'json' => [ + 'label' => 'IDE_ExampleIDE_215824ff272a4a8c9027df32ed1d68a9', + 'public_key' => $request['public_key'], + ], ]; $this->mockRequest('postAccountSshKeys', null, $body); @@ -95,7 +95,7 @@ protected function runTestCreate(): void // Set properties and execute. $this->executeCommand([], [ // Would you like to link the project at ... ? - 'y', + 'y', ]); // Assertions. @@ -129,10 +129,10 @@ protected function runTestSshKeyAlreadyUploaded(): void $localMachineHelper = $this->mockLocalMachineHelper(); $body = [ - 'json' => [ - 'label' => 'IDE_ExampleIDE_215824ff272a4a8c9027df32ed1d68a9', - 'public_key' => $mockRequestArgs['public_key'], - ], + 'json' => [ + 'label' => 'IDE_ExampleIDE_215824ff272a4a8c9027df32ed1d68a9', + 'public_key' => $mockRequestArgs['public_key'], + ], ]; $this->mockRequest('postAccountSshKeys', null, $body); @@ -164,7 +164,7 @@ protected function runTestSshKeyAlreadyUploaded(): void protected function getOutputStrings(): array { return [ - "Setting GitLab CI/CD variables for", + "Setting GitLab CI/CD variables for", ]; } } diff --git a/tests/phpunit/src/Misc/EnvDbCredsTest.php b/tests/phpunit/src/Misc/EnvDbCredsTest.php index 3bbff0c8b..4444804a7 100644 --- a/tests/phpunit/src/Misc/EnvDbCredsTest.php +++ b/tests/phpunit/src/Misc/EnvDbCredsTest.php @@ -41,10 +41,10 @@ public function tearDown(): void protected function getEnvVars(): array { return [ - 'ACLI_DB_HOST' => $this->dbHost, - 'ACLI_DB_NAME' => $this->dbName, - 'ACLI_DB_PASSWORD' => $this->dbPassword, - 'ACLI_DB_USER' => $this->dbUser, + 'ACLI_DB_HOST' => $this->dbHost, + 'ACLI_DB_NAME' => $this->dbName, + 'ACLI_DB_PASSWORD' => $this->dbPassword, + 'ACLI_DB_USER' => $this->dbUser, ]; } diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index 95517e376..b38af09d9 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -49,66 +49,66 @@ public function testHelp(Throwable $error, string|array $helpText): void public function providerTestHelp(): array { return [ - [ - new IdentityProviderException('invalid_client', 0, ''), - 'Run acli auth:login to reset your API credentials.', - ], - [ - new RuntimeException('Not enough arguments (missing: "environmentId").'), - self::$siteAliasHelp, - ], - [ - new RuntimeException('Not enough arguments (missing: "environmentUuid").'), - self::$siteAliasHelp, - ], - [ - new AcquiaCliException('No applications match the alias {applicationAlias}'), - self::$appAliasHelp, - ], - [ - new AcquiaCliException('Multiple applications match the alias {applicationAlias}'), - self::$appAliasHelp, - ], - [ - new AcquiaCliException('{environmentId} must be a valid UUID or site alias.'), - self::$siteAliasHelp, - ], - [ - new AcquiaCliException('{environmentUuid} must be a valid UUID or site alias.'), - self::$siteAliasHelp, - ], - [ - new AcquiaCliException('Access token file not found at {file}'), - 'Get help for this error at https://docs.acquia.com/ide/known-issues/#the-automated-cloud-platform-api-authentication-might-fail', - ], - [ - new AcquiaCliException('Access token expiry file not found at {file}'), - 'Get help for this error at https://docs.acquia.com/ide/known-issues/#the-automated-cloud-platform-api-authentication-might-fail', - ], - [ - new AcquiaCliException('This machine is not yet authenticated with the Cloud Platform.'), - 'Run `acli auth:login` to re-authenticated with the Cloud Platform.', - ], - [ - new AcquiaCliException('This machine is not yet authenticated with Site Factory.'), - 'Run `acli auth:acsf-login` to re-authenticate with Site Factory.', - ], - [ - new AcquiaCliException('Could not extract aliases to {destination}'), - 'Check that you have write access to the directory', - ], - [ - new ApiErrorException((object) ['error' => '', 'message' => "There are no available Cloud IDEs for this application.\n"]), - 'Delete an existing IDE via acli ide:delete or contact your Account Manager or Acquia Sales to purchase additional IDEs.', - ], - [ - new ApiErrorException((object) ['error' => '', 'message' => 'This resource requires additional authentication.']), - ['This is likely because you have Federated Authentication required for your organization.', 'Run `acli login` to authenticate via API token and then try again.'], - ], - [ - new ApiErrorException((object) ['error' => 'asdf', 'message' => 'fdsa']), - 'You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/', - ], + [ + new IdentityProviderException('invalid_client', 0, ''), + 'Run acli auth:login to reset your API credentials.', + ], + [ + new RuntimeException('Not enough arguments (missing: "environmentId").'), + self::$siteAliasHelp, + ], + [ + new RuntimeException('Not enough arguments (missing: "environmentUuid").'), + self::$siteAliasHelp, + ], + [ + new AcquiaCliException('No applications match the alias {applicationAlias}'), + self::$appAliasHelp, + ], + [ + new AcquiaCliException('Multiple applications match the alias {applicationAlias}'), + self::$appAliasHelp, + ], + [ + new AcquiaCliException('{environmentId} must be a valid UUID or site alias.'), + self::$siteAliasHelp, + ], + [ + new AcquiaCliException('{environmentUuid} must be a valid UUID or site alias.'), + self::$siteAliasHelp, + ], + [ + new AcquiaCliException('Access token file not found at {file}'), + 'Get help for this error at https://docs.acquia.com/ide/known-issues/#the-automated-cloud-platform-api-authentication-might-fail', + ], + [ + new AcquiaCliException('Access token expiry file not found at {file}'), + 'Get help for this error at https://docs.acquia.com/ide/known-issues/#the-automated-cloud-platform-api-authentication-might-fail', + ], + [ + new AcquiaCliException('This machine is not yet authenticated with the Cloud Platform.'), + 'Run `acli auth:login` to re-authenticated with the Cloud Platform.', + ], + [ + new AcquiaCliException('This machine is not yet authenticated with Site Factory.'), + 'Run `acli auth:acsf-login` to re-authenticate with Site Factory.', + ], + [ + new AcquiaCliException('Could not extract aliases to {destination}'), + 'Check that you have write access to the directory', + ], + [ + new ApiErrorException((object) ['error' => '', 'message' => "There are no available Cloud IDEs for this application.\n"]), + 'Delete an existing IDE via acli ide:delete or contact your Account Manager or Acquia Sales to purchase additional IDEs.', + ], + [ + new ApiErrorException((object) ['error' => '', 'message' => 'This resource requires additional authentication.']), + ['This is likely because you have Federated Authentication required for your organization.', 'Run `acli login` to authenticate via API token and then try again.'], + ], + [ + new ApiErrorException((object) ['error' => 'asdf', 'message' => 'fdsa']), + 'You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/', + ], ]; } } diff --git a/tests/phpunit/src/Misc/LocalMachineHelperTest.php b/tests/phpunit/src/Misc/LocalMachineHelperTest.php index a9ac9b51d..18d97bb50 100644 --- a/tests/phpunit/src/Misc/LocalMachineHelperTest.php +++ b/tests/phpunit/src/Misc/LocalMachineHelperTest.php @@ -26,9 +26,9 @@ public function testStartBrowser(): void public function providerTestExecuteFromCmd(): array { return [ - [false, null, null], - [false, false, false], - [true, false, false], + [false, null, null], + [false, false, false], + [true, false, false], ]; } @@ -70,11 +70,11 @@ public function testCommandExists(): void public function testHomeDirWindowsCmd(): void { self::setEnvVars([ - 'HOMEPATH' => 'something', + 'HOMEPATH' => 'something', ]); self::unsetEnvVars([ - 'MSYSTEM', - 'HOME', + 'MSYSTEM', + 'HOME', ]); $home = LocalMachineHelper::getHomeDir(); $this->assertEquals('something', $home); @@ -83,8 +83,8 @@ public function testHomeDirWindowsCmd(): void public function testHomeDirWindowsMsys2(): void { self::setEnvVars([ - 'HOMEPATH' => 'something', - 'MSYSTEM' => 'MSYS2', + 'HOMEPATH' => 'something', + 'MSYSTEM' => 'MSYS2', ]); self::unsetEnvVars(['HOME']); $home = LocalMachineHelper::getHomeDir(); diff --git a/tests/phpunit/src/Misc/TelemetryHelperTest.php b/tests/phpunit/src/Misc/TelemetryHelperTest.php index 709ba842b..7e4c2d57d 100644 --- a/tests/phpunit/src/Misc/TelemetryHelperTest.php +++ b/tests/phpunit/src/Misc/TelemetryHelperTest.php @@ -80,14 +80,14 @@ public function testGetEnvironmentProviderWithoutAnyEnvSet(): void public function providerTestAhEnvNormalization(): array { return [ - ['prod', 'prod'], - ['01live', 'prod'], - ['stage', 'stage'], - ['stg', 'stage'], - ['dev1', 'dev'], - ['ode1', 'ode'], - ['ide', 'ide'], - ['fake', 'fake'], + ['prod', 'prod'], + ['01live', 'prod'], + ['stage', 'stage'], + ['stg', 'stage'], + ['dev1', 'dev'], + ['ode1', 'ode'], + ['ide', 'ide'], + ['fake', 'fake'], ]; } diff --git a/tests/phpunit/src/TestBase.php b/tests/phpunit/src/TestBase.php index efe15ed6c..a51ec15d2 100644 --- a/tests/phpunit/src/TestBase.php +++ b/tests/phpunit/src/TestBase.php @@ -162,8 +162,8 @@ public function setupFsFixture(): void protected function setUp(): void { self::setEnvVars([ - 'COLUMNS' => '85', - 'HOME' => '/home/test', + 'COLUMNS' => '85', + 'HOME' => '/home/test', ]); $this->output = new BufferedOutput(); $this->input = new ArrayInput([]); @@ -423,15 +423,15 @@ protected function createMockCloudConfigFile(mixed $defaultValues = []): void { if (!$defaultValues) { $defaultValues = [ - 'acli_key' => $this->key, - 'keys' => [ - (string) ($this->key) => [ - 'label' => 'Test Key', - 'secret' => $this->secret, - 'uuid' => $this->key, - ], - ], - DataStoreContract::SEND_TELEMETRY => false, + 'acli_key' => $this->key, + 'keys' => [ + (string) ($this->key) => [ + 'label' => 'Test Key', + 'secret' => $this->secret, + 'uuid' => $this->key, + ], + ], + DataStoreContract::SEND_TELEMETRY => false, ]; } $cloudConfig = array_merge($defaultValues, $this->cloudConfig); @@ -504,8 +504,8 @@ public function mockApplicationsRequest(int $count = 2, bool $unique = true): ob public function mockUnauthorizedRequest(): void { $response = [ - 'error' => 'invalid_client', - 'error_description' => 'Client credentials were not found in the headers or body', + 'error' => 'invalid_client', + 'error_description' => 'Client credentials were not found in the headers or body', ]; $this->clientProphecy->request('get', Argument::type('string')) ->willThrow(new IdentityProviderException($response['error'], 0, $response)); @@ -514,8 +514,8 @@ public function mockUnauthorizedRequest(): void public function mockApiError(): void { $response = (object) [ - 'error' => 'some error', - 'message' => 'some error', + 'error' => 'some error', + 'message' => 'some error', ]; $this->clientProphecy->request('get', Argument::type('string')) ->willThrow(new ApiErrorException($response, $response->message)); @@ -524,8 +524,8 @@ public function mockApiError(): void public function mockNoAvailableIdes(): void { $response = (object) [ - 'error' => "There are no available Cloud IDEs for this application.\n", - 'message' => "There are no available Cloud IDEs for this application.\n", + 'error' => "There are no available Cloud IDEs for this application.\n", + 'message' => "There are no available Cloud IDEs for this application.\n", ]; $this->clientProphecy->request('get', Argument::type('string')) ->willThrow(new ApiErrorException($response, $response->message)); @@ -558,9 +558,9 @@ protected function mockPermissionsRequest(mixed $applicationResponse, mixed $per ); if (!$perms) { $deletePerms = [ - 'add ssh key to git', - 'add ssh key to non-prod', - 'add ssh key to prod', + 'add ssh key to git', + 'add ssh key to non-prod', + 'add ssh key to prod', ]; foreach ($permissionsResponse->_embedded->items as $index => $item) { if (in_array($item->name, $deletePerms, true)) { @@ -663,8 +663,8 @@ protected function mockSshAgentList(ObjectProphecy|LocalMachineHelper $localMach $localMachineHelper->getLocalFilepath($this->passphraseFilepath) ->willReturn('/tmp/.passphrase'); $localMachineHelper->execute([ - 'ssh-add', - '-L', + 'ssh-add', + '-L', ], null, null, false)->shouldBeCalled()->willReturn($process->reveal()); } @@ -694,9 +694,9 @@ protected function mockStartPhp(ObjectProphecy|LocalMachineHelper $localMachineH $process->isSuccessful()->willReturn(true); $process->getExitCode()->willReturn(0); $localMachineHelper->execute([ - 'supervisorctl', - 'start', - 'php-fpm', + 'supervisorctl', + 'start', + 'php-fpm', ], null, null, false)->willReturn($process->reveal())->shouldBeCalled(); return $process; } @@ -707,9 +707,9 @@ protected function mockStopPhp(ObjectProphecy|LocalMachineHelper $localMachineHe $process->isSuccessful()->willReturn(true); $process->getExitCode()->willReturn(0); $localMachineHelper->execute([ - 'supervisorctl', - 'stop', - 'php-fpm', + 'supervisorctl', + 'stop', + 'php-fpm', ], null, null, false)->willReturn($process->reveal())->shouldBeCalled(); return $process; } @@ -720,9 +720,9 @@ protected function mockRestartPhp(ObjectProphecy|LocalMachineHelper $localMachin $process->isSuccessful()->willReturn(true); $process->getExitCode()->willReturn(0); $localMachineHelper->execute([ - 'supervisorctl', - 'restart', - 'php-fpm', + 'supervisorctl', + 'restart', + 'php-fpm', ], null, null, false)->willReturn($process->reveal())->shouldBeCalled(); return $process; } From 285ba0946aa896c2de9f727a7a04e76de0d9abea Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 11 Jul 2024 12:14:52 -0700 Subject: [PATCH 2/4] format code --- src/AcsfApi/AcsfClient.php | 7 +- src/CloudApi/ClientService.php | 7 +- src/Command/Api/ApiBaseCommand.php | 15 +- src/Command/Api/ApiCommandHelper.php | 27 ++- src/Command/App/AppOpenCommand.php | 7 +- src/Command/App/AppVcsInfo.php | 8 +- .../App/From/Composer/ProjectBuilder.php | 15 +- src/Command/App/From/Configuration.php | 3 +- .../AbandonmentRecommendation.php | 13 +- .../Recommendation/DefinedRecommendation.php | 13 +- .../Recommendation/NormalizableInterface.php | 3 +- .../RecommendationInterface.php | 11 +- .../App/From/Recommendation/Resolver.php | 4 +- .../App/From/Safety/ArrayValidationTrait.php | 7 +- .../From/Safety/StructuredArrayValidator.php | 11 +- .../From/SourceSite/Drupal7SiteInspector.php | 11 +- .../SourceSite/SiteInspectorInterface.php | 13 +- src/Command/App/LogTailCommand.php | 7 +- src/Command/App/NewCommand.php | 7 +- src/Command/App/NewFromDrupal7Command.php | 29 +-- src/Command/App/TaskWaitCommand.php | 6 +- src/Command/Archive/ArchiveExportCommand.php | 31 ++- src/Command/Auth/AuthAcsfLoginCommand.php | 6 +- src/Command/Auth/AuthLoginCommand.php | 6 +- .../CodeStudio/CodeStudioCiCdVariables.php | 8 +- .../CodeStudio/CodeStudioCommandTrait.php | 15 +- .../CodeStudioPhpVersionCommand.php | 15 +- .../CodeStudioPipelinesMigrateCommand.php | 48 ++-- .../CodeStudio/CodeStudioWizardCommand.php | 99 ++++---- src/Command/CommandBase.php | 144 ++++++++---- src/Command/DocsCommand.php | 26 ++- .../Email/EmailInfoForSubscriptionCommand.php | 61 +++-- src/Command/Env/EnvCertCreateCommand.php | 14 +- src/Command/Env/EnvCopyCronCommand.php | 24 +- src/Command/Env/EnvMirrorCommand.php | 12 +- src/Command/Ide/IdeCreateCommand.php | 7 +- src/Command/Ide/IdeOpenCommand.php | 2 +- src/Command/Ide/IdePhpVersionCommand.php | 7 +- src/Command/Ide/IdeServiceRestartCommand.php | 19 +- src/Command/Ide/IdeServiceStartCommand.php | 19 +- src/Command/Ide/IdeServiceStopCommand.php | 19 +- src/Command/Ide/IdeShareCommand.php | 4 +- src/Command/Ide/IdeXdebugToggleCommand.php | 2 +- .../Wizard/IdeWizardCreateSshKeyCommand.php | 6 +- .../Wizard/IdeWizardDeleteSshKeyCommand.php | 2 +- src/Command/Pull/PullCodeCommand.php | 16 +- src/Command/Pull/PullCommand.php | 29 +-- src/Command/Pull/PullCommandBase.php | 31 ++- src/Command/Pull/PullDatabaseCommand.php | 54 ++--- src/Command/Pull/PullFilesCommand.php | 4 +- src/Command/Pull/PullScriptsCommand.php | 4 +- src/Command/Push/PushArtifactCommand.php | 124 ++++++---- src/Command/Push/PushCodeCommand.php | 2 +- src/Command/Push/PushDatabaseCommand.php | 4 +- src/Command/Push/PushFilesCommand.php | 4 +- src/Command/Remote/AliasListCommand.php | 17 +- src/Command/Remote/AliasesDownloadCommand.php | 7 +- src/Command/Remote/DrushCommand.php | 20 +- src/Command/Remote/SshCommand.php | 11 +- src/Command/Self/ClearCacheCommand.php | 5 +- src/Command/Self/ListCommand.php | 20 +- src/Command/Ssh/SshKeyCommandBase.php | 40 +++- src/Command/Ssh/SshKeyCreateCommand.php | 4 +- src/Command/Ssh/SshKeyCreateUploadCommand.php | 8 +- src/Command/Ssh/SshKeyDeleteCommand.php | 2 +- src/Command/Ssh/SshKeyInfoCommand.php | 4 +- src/Command/Ssh/SshKeyListCommand.php | 6 +- src/Command/Ssh/SshKeyUploadCommand.php | 6 +- src/Config/AcquiaCliConfig.php | 10 +- src/Config/CloudDataConfig.php | 86 ++++--- src/EventListener/ComposerScriptsListener.php | 17 +- src/EventListener/ExceptionListener.php | 6 +- src/Exception/AcquiaCliException.php | 3 +- src/Helpers/DataStoreContract.php | 1 + src/Helpers/LocalMachineHelper.php | 46 ++-- src/Helpers/LoopHelper.php | 3 +- src/Helpers/SshCommandTrait.php | 12 +- src/Helpers/TelemetryHelper.php | 7 +- src/Kernel.php | 10 +- src/Output/Checklist.php | 2 +- src/Output/Spinner/Spinner.php | 3 +- tests/phpunit/src/AcsfApi/AcsfServiceTest.php | 6 +- tests/phpunit/src/ApplicationTestBase.php | 6 +- .../src/CloudApi/AccessTokenConnectorTest.php | 17 +- .../src/CloudApi/AcsfClientServiceTest.php | 37 ++- .../src/CloudApi/ClientServiceTest.php | 30 ++- tests/phpunit/src/CommandTestBase.php | 104 +++++---- .../src/Commands/Acsf/AcsfApiCommandTest.php | 105 +++++++-- .../Acsf/AcsfAuthLoginCommandTest.php | 37 +-- .../Acsf/AcsfAuthLogoutCommandTest.php | 15 +- .../src/Commands/Api/ApiCommandTest.php | 186 ++++++++++----- .../src/Commands/App/AppOpenCommandTest.php | 3 +- .../src/Commands/App/AppVcsInfoTest.php | 12 +- .../Commands/App/From/ConfigurationTest.php | 10 +- .../App/From/DefinedRecommendationTest.php | 12 +- .../Commands/App/From/RecommendationsTest.php | 3 +- .../src/Commands/App/LinkCommandTest.php | 4 +- .../src/Commands/App/LogTailCommandTest.php | 30 +-- .../src/Commands/App/NewCommandTest.php | 53 +++-- .../App/NewFromDrupal7CommandTest.php | 44 ++-- .../Archive/ArchiveExporterCommandTest.php | 26 ++- .../Commands/Auth/AuthLoginCommandTest.php | 32 ++- .../Commands/Auth/AuthLogoutCommandTest.php | 3 +- tests/phpunit/src/Commands/ChecklistTest.php | 5 +- .../src/Commands/ClearCacheCommandTest.php | 11 +- .../CodeStudioPhpVersionCommandTest.php | 13 +- .../CodeStudioPipelinesMigrateCommandTest.php | 24 +- .../CodeStudioWizardCommandTest.php | 196 +++++++++------- .../phpunit/src/Commands/CommandBaseTest.php | 30 ++- .../EmailInfoForSubscriptionCommandTest.php | 45 ++-- .../Commands/Env/EnvCertCreateCommandTest.php | 32 ++- .../Commands/Env/EnvCopyCronCommandTest.php | 18 +- .../src/Commands/Env/EnvCreateCommandTest.php | 22 +- .../src/Commands/Env/EnvDeleteCommandTest.php | 32 +-- .../src/Commands/Env/EnvMirrorCommandTest.php | 22 +- .../src/Commands/Ide/IdeCreateCommandTest.php | 10 +- .../src/Commands/Ide/IdeDeleteCommandTest.php | 22 +- tests/phpunit/src/Commands/Ide/IdeHelper.php | 1 + .../src/Commands/Ide/IdeInfoCommandTest.php | 8 +- .../Commands/Ide/IdeListCommandMineTest.php | 14 +- .../src/Commands/Ide/IdeListCommandTest.php | 16 +- .../src/Commands/Ide/IdeOpenCommandTest.php | 11 +- .../Commands/Ide/IdePhpVersionCommandTest.php | 7 +- .../Ide/IdeXdebugToggleCommandTest.php | 14 +- .../IdeWizardCreateSshKeyCommandTest.php | 3 +- .../IdeWizardDeleteSshKeyCommandTest.php | 3 +- .../src/Commands/InferApplicationTest.php | 22 +- .../src/Commands/Pull/PullCodeCommandTest.php | 48 ++-- .../src/Commands/Pull/PullCommandTest.php | 19 +- .../src/Commands/Pull/PullCommandTestBase.php | 219 ++++++++++-------- .../Commands/Pull/PullDatabaseCommandTest.php | 35 +-- .../Commands/Pull/PullFilesCommandTest.php | 20 +- .../Commands/Pull/PullScriptsCommandTest.php | 8 +- .../Commands/Push/PushArtifactCommandTest.php | 171 ++++++++++---- .../Commands/Push/PushDatabaseCommandTest.php | 59 +++-- .../Commands/Push/PushFilesCommandTest.php | 50 ++-- .../Remote/AliasesDownloadCommandTest.php | 11 +- .../Remote/AliasesListCommandTest.php | 6 +- .../src/Commands/Remote/DrushCommandTest.php | 9 +- .../src/Commands/Remote/SshCommandTest.php | 9 +- .../Commands/Remote/SshCommandTestBase.php | 3 +- .../Commands/Ssh/SshKeyCreateCommandTest.php | 25 +- .../Ssh/SshKeyCreateUploadCommandTest.php | 13 +- .../Commands/Ssh/SshKeyDeleteCommandTest.php | 4 +- .../Commands/Ssh/SshKeyInfoCommandTest.php | 2 +- .../Commands/Ssh/SshKeyListCommandTest.php | 4 +- .../Commands/Ssh/SshKeyUploadCommandTest.php | 42 ++-- .../src/Commands/TelemetryCommandTest.php | 2 +- .../src/Commands/UpdateCommandTest.php | 2 +- tests/phpunit/src/Commands/WizardTestBase.php | 39 ++-- .../src/Misc/ExceptionListenerTest.php | 29 ++- .../src/Misc/LocalMachineHelperTest.php | 5 +- .../phpunit/src/Misc/TelemetryHelperTest.php | 3 +- tests/phpunit/src/TestBase.php | 111 +++++---- 154 files changed, 2313 insertions(+), 1439 deletions(-) diff --git a/src/AcsfApi/AcsfClient.php b/src/AcsfApi/AcsfClient.php index 63a94eeb0..15d794b42 100644 --- a/src/AcsfApi/AcsfClient.php +++ b/src/AcsfApi/AcsfClient.php @@ -28,7 +28,12 @@ public function processResponse(ResponseInterface $response): mixed throw new ApiErrorException($body); } // Throw error for 4xx and 5xx responses. - if (property_exists($body, 'message') && in_array(substr((string) $response->getStatusCode(), 0, 1), ['4', '5'], true)) { + if ( + property_exists($body, 'message') && in_array(substr((string) $response->getStatusCode(), 0, 1), [ + '4', + '5', + ], true) + ) { $body->error = $response->getStatusCode(); throw new ApiErrorException($body); } diff --git a/src/CloudApi/ClientService.php b/src/CloudApi/ClientService.php index 5021deaca..357dda551 100644 --- a/src/CloudApi/ClientService.php +++ b/src/CloudApi/ClientService.php @@ -20,8 +20,11 @@ class ClientService { protected ConnectorInterface $connector; + protected ConnectorFactoryInterface|ConnectorFactory $connectorFactory; + protected Application $application; + protected ?bool $machineIsAuthenticated = null; public function __construct(ConnectorFactoryInterface $connectorFactory, Application $application, protected ApiCredentialsInterface $credentials) @@ -73,8 +76,8 @@ public function isMachineAuthenticated(): bool protected function checkAuthentication(): bool { return ( - $this->credentials->getCloudAccessToken() || - ($this->credentials->getCloudKey() && $this->credentials->getCloudSecret()) + $this->credentials->getCloudAccessToken() || + ($this->credentials->getCloudKey() && $this->credentials->getCloudSecret()) ); } } diff --git a/src/Command/Api/ApiBaseCommand.php b/src/Command/Api/ApiBaseCommand.php index f6c05e099..8f3fc52ea 100644 --- a/src/Command/Api/ApiBaseCommand.php +++ b/src/Command/Api/ApiBaseCommand.php @@ -71,14 +71,17 @@ protected function interact(InputInterface $input, OutputInterface $output): voi && array_key_exists('schema', $params[$argument->getName()]) && array_key_exists('enum', $params[$argument->getName()]['schema']) ) { - $choices = $params[$argument->getName()]['schema']['enum']; - $answer = $this->io->choice("Select a value for {$argument->getName()}", $choices, $argument->getDefault()); + $choices = $params[$argument->getName()]['schema']['enum']; + $answer = $this->io->choice("Select a value for {$argument->getName()}", $choices, $argument->getDefault()); } elseif ( array_key_exists($argument->getName(), $params) && array_key_exists('type', $params[$argument->getName()]) && $params[$argument->getName()]['type'] === 'boolean' ) { - $answer = $this->io->choice("Select a value for {$argument->getName()}", ['false', 'true'], $argument->getDefault()); + $answer = $this->io->choice("Select a value for {$argument->getName()}", [ + 'false', + 'true', + ], $argument->getDefault()); $answer = $answer === 'true'; } else { // Free form. @@ -327,7 +330,7 @@ private function createValidatorFromConstraints(array $constraints): Closure { return static function (mixed $value) use ($constraints) { $violations = Validation::createValidator() - ->validate($value, $constraints); + ->validate($value, $constraints); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); } @@ -362,8 +365,8 @@ private function addPostParamsToClient(InputInterface $input, Client $acquiaClou } /** - * @param array|null $paramSpec - */ + * @param array|null $paramSpec + */ private function addPostParamToClient(string $paramName, ?array $paramSpec, mixed $paramValue, Client $acquiaCloudClient): void { $paramName = ApiCommandHelper::restoreRenamedParameter($paramName); diff --git a/src/Command/Api/ApiCommandHelper.php b/src/Command/Api/ApiCommandHelper.php index 2be9124e7..bbe360d15 100644 --- a/src/Command/Api/ApiCommandHelper.php +++ b/src/Command/Api/ApiCommandHelper.php @@ -67,7 +67,10 @@ private function addApiCommandParameters(array $schema, array $acquiaCloudSpec, // Parameters to be used in the request query and path. if (array_key_exists('parameters', $schema)) { - [$queryInputDefinition, $queryParamUsageSuffix] = $this->addApiCommandParametersForPathAndQuery($schema, $acquiaCloudSpec); + [ + $queryInputDefinition, + $queryParamUsageSuffix, + ] = $this->addApiCommandParametersForPathAndQuery($schema, $acquiaCloudSpec); /** @var \Symfony\Component\Console\Input\InputOption|InputArgument $parameterDefinition */ foreach ($queryInputDefinition as $parameterDefinition) { $parameterSpecification = $this->getParameterDefinitionFromSpec($parameterDefinition->getName(), $acquiaCloudSpec, $schema); @@ -175,11 +178,11 @@ private function addPostArgumentUsageToExample(mixed $requestBody, mixed $propKe $usage .= $prefix . "\"$value\" "; } } else { - // @todo Pretty sure prevents the user from using the arguments. - // Probably a bug. How can we allow users to specify a multidimensional array as an - // argument? - $value = json_encode($example[$propKey], JSON_THROW_ON_ERROR); - $usage .= $prefix . "\"$value\" "; + // @todo Pretty sure prevents the user from using the arguments. + // Probably a bug. How can we allow users to specify a multidimensional array as an + // argument? + $value = json_encode($example[$propKey], JSON_THROW_ON_ERROR); + $usage .= $prefix . "\"$value\" "; } break; @@ -365,10 +368,10 @@ private function generateApiCommandsFromSpec(array $acquiaCloudSpec, string $com protected function getSkippedApiCommands(): array { return [ - // Skip accounts:drush-aliases since we have remote:aliases:download instead and it actually returns - // application/gzip content. + // Skip accounts:drush-aliases since we have remote:aliases:download instead and it actually returns + // application/gzip content. 'accounts:drush-aliases', - // Skip any command that has a duplicative corresponding ACLI command. + // Skip any command that has a duplicative corresponding ACLI command. 'ide:create', 'log:tail', 'ssh-key:create', @@ -376,7 +379,7 @@ protected function getSkippedApiCommands(): array 'ssh-key:delete', 'ssh-key:list', 'ssh-key:upload', - // Skip buggy or unsupported endpoints. + // Skip buggy or unsupported endpoints. 'environments:stack-metrics-data-metric', ]; } @@ -439,9 +442,9 @@ protected static function getParameterRenameMap(): array { // Format should be ['original => new']. return [ - // @see api:environments:cron-create + // @see api:environments:cron-create 'command' => 'cron_command', - // @see api:environments:update. + // @see api:environments:update. 'version' => 'lang_version', ]; } diff --git a/src/Command/App/AppOpenCommand.php b/src/Command/App/AppOpenCommand.php index 386154d3b..c0a33de03 100644 --- a/src/Command/App/AppOpenCommand.php +++ b/src/Command/App/AppOpenCommand.php @@ -13,13 +13,16 @@ use Symfony\Component\Console\Output\OutputInterface; #[RequireAuth] -#[AsCommand(name: 'app:open', description: 'Opens your browser to view a given Cloud application', aliases: ['open', 'o'])] +#[AsCommand(name: 'app:open', description: 'Opens your browser to view a given Cloud application', aliases: [ + 'open', + 'o', +])] final class AppOpenCommand extends CommandBase { protected function configure(): void { $this - ->acceptApplicationUuid(); + ->acceptApplicationUuid(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/App/AppVcsInfo.php b/src/Command/App/AppVcsInfo.php index 0d7c868fb..f41aa9e4f 100644 --- a/src/Command/App/AppVcsInfo.php +++ b/src/Command/App/AppVcsInfo.php @@ -22,8 +22,8 @@ class AppVcsInfo extends CommandBase protected function configure(): void { $this - ->addOption('deployed', null, InputOption::VALUE_OPTIONAL, 'Show only deployed branches and tags') - ->addUsage('[] --deployed'); + ->addOption('deployed', null, InputOption::VALUE_OPTIONAL, 'Show only deployed branches and tags') + ->addUsage('[] --deployed'); $this->acceptApplicationUuid(); } @@ -83,9 +83,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($allVcs as $vscPath => $env) { $table->addRow([ $vscPath, - // If VCS and env name is not same, it means it is deployed. + // If VCS and env name is not same, it means it is deployed. $vscPath !== $env ? 'Yes' : 'No', - // If VCS and env name is same, it means it is deployed. + // If VCS and env name is same, it means it is deployed. $vscPath !== $env ? $env : 'None', ]); } diff --git a/src/Command/App/From/Composer/ProjectBuilder.php b/src/Command/App/From/Composer/ProjectBuilder.php index 2aface12f..a2b765013 100644 --- a/src/Command/App/From/Composer/ProjectBuilder.php +++ b/src/Command/App/From/Composer/ProjectBuilder.php @@ -50,14 +50,15 @@ public function __construct(Configuration $configuration, Resolver $recommendati } /** - * Gets an array representing a D9+ composer.json file for the current site. + * Gets an array representing a D9+ composer.json file for the current + * site. * * @return array * An array that can be encoded as JSON and written to a file. Calling - * `composer install` in the same directory as that file should yield a new - * Drupal project with Drupal 9+ installed, in addition to the Acquia - * Migrate module, and some of all of the D9 replacements for the current - * site's Drupal 7 modules. + * `composer install` in the same directory as that file should yield a + * new Drupal project with Drupal 9+ installed, in addition to the + * Acquia Migrate module, and some of all of the D9 replacements for + * the current site's Drupal 7 modules. */ public function buildProject(): array { @@ -125,13 +126,13 @@ public function buildProject(): array } $source_modules = array_values(array_map(function (ExtensionInterface $module) { - // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys + // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return [ 'name' => $module->getName(), 'humanName' => $module->getHumanName(), 'version' => $module->getVersion(), ]; - // phpcs:enable + // phpcs:enable }, $this->siteInspector->getExtensions(SiteInspectorInterface::FLAG_EXTENSION_MODULE | SiteInspectorInterface::FLAG_EXTENSION_ENABLED))); $module_names = array_column($source_modules, 'name'); array_multisort($module_names, SORT_STRING, $source_modules); diff --git a/src/Command/App/From/Configuration.php b/src/Command/App/From/Configuration.php index 30116a4e8..1d90146e0 100644 --- a/src/Command/App/From/Configuration.php +++ b/src/Command/App/From/Configuration.php @@ -35,7 +35,8 @@ protected function __construct(array $config) } /** - * Creates a configuration object from configuration given as a PHP resource. + * Creates a configuration object from configuration given as a PHP + * resource. * * The given PHP resource is usually obtained by calling fopen($location). * diff --git a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php index c90a1709a..8102cca80 100644 --- a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php +++ b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php @@ -18,7 +18,8 @@ class AbandonmentRecommendation implements RecommendationInterface, Normalizable use ArrayValidationTrait; /** - * An anonymous function that determines if this recommendation is applicable. + * An anonymous function that determines if this recommendation is + * applicable. */ protected \Closure $evaluateExtension; @@ -55,12 +56,12 @@ protected function __construct(Closure $extension_evaluator, array $definition) * Creates a new recommendation. * * @param mixed $definition - * A static recommendation definition. This must be an array. However, other - * value types are accepted because this method performs validation on the - * given value. + * A static recommendation definition. This must be an array. However, + * other value types are accepted because this method performs + * validation on the given value. * @return \Acquia\Cli\Command\App\From\Recommendation\RecommendationInterface - * A new AbandonmentRecommendation object if the given definition is valid or - * a new NoRecommendation object otherwise. + * A new AbandonmentRecommendation object if the given definition is + * valid or a new NoRecommendation object otherwise. */ public static function createFromDefinition(mixed $definition): RecommendationInterface { diff --git a/src/Command/App/From/Recommendation/DefinedRecommendation.php b/src/Command/App/From/Recommendation/DefinedRecommendation.php index 1524be745..a59677d99 100644 --- a/src/Command/App/From/Recommendation/DefinedRecommendation.php +++ b/src/Command/App/From/Recommendation/DefinedRecommendation.php @@ -26,7 +26,8 @@ class DefinedRecommendation implements RecommendationInterface, NormalizableInte protected const NOTE_PLACEHOLDER_STRING = '%note%'; /** - * An anonymous function that determines if this recommendation is applicable. + * An anonymous function that determines if this recommendation is + * applicable. */ protected \Closure $evaluateExtension; @@ -60,8 +61,8 @@ class DefinedRecommendation implements RecommendationInterface, NormalizableInte /** * A list of recommended patches. * - * The keys of the array should be descriptions of the patch contents and the - * values should be URLs where the recommended patch can be downloaded. + * The keys of the array should be descriptions of the patch contents and + * the values should be URLs where the recommended patch can be downloaded. * * @var array */ @@ -108,9 +109,9 @@ protected function __construct(Closure $extension_evaluator, string $package_nam * Creates a new recommendation. * * @param mixed $definition - * A static recommendation definition. This must be an array. However, other - * value types are accepted because this method performs validation on the - * given value. + * A static recommendation definition. This must be an array. However, + * other value types are accepted because this method performs + * validation on the given value. * @return \Acquia\Cli\Command\App\From\Recommendation\RecommendationInterface * A new DefinedRecommendation object if the given definition is valid or * a new NoRecommendation object otherwise. diff --git a/src/Command/App/From/Recommendation/NormalizableInterface.php b/src/Command/App/From/Recommendation/NormalizableInterface.php index e4c32b62a..e3927247f 100644 --- a/src/Command/App/From/Recommendation/NormalizableInterface.php +++ b/src/Command/App/From/Recommendation/NormalizableInterface.php @@ -10,7 +10,8 @@ interface NormalizableInterface { /** - * Normalizes an object into a single- or multi-dimensional array of scalars. + * Normalizes an object into a single- or multi-dimensional array of + * scalars. * * @return array */ diff --git a/src/Command/App/From/Recommendation/RecommendationInterface.php b/src/Command/App/From/Recommendation/RecommendationInterface.php index e7343df35..632211117 100644 --- a/src/Command/App/From/Recommendation/RecommendationInterface.php +++ b/src/Command/App/From/Recommendation/RecommendationInterface.php @@ -22,7 +22,8 @@ interface RecommendationInterface public function applies(ExtensionInterface $extension): bool; /** - * The recommended composer package name to replace the applicable extension. + * The recommended composer package name to replace the applicable + * extension. * * @return string * The recommended package's name. @@ -41,7 +42,8 @@ public function getVersionConstraint(): string; * Whether this recommendation contains modules to install. * * @return bool - * TRUE if the recommendation includes modules to install, FALSE otherwise. + * TRUE if the recommendation includes modules to install, FALSE + * otherwise. */ public function hasModulesToInstall(): bool; @@ -74,8 +76,9 @@ public function hasPatches(): bool; * Gets an array of recommended patches for the recommended package. * * @return array - * An associative array whose keys are a description of the patch's contents - * and whose values are URLs or relative paths to a patch file. + * An associative array whose keys are a description of the patch's + * contents and whose values are URLs or relative paths to a patch + * file. */ public function getPatches(): array; } diff --git a/src/Command/App/From/Recommendation/Resolver.php b/src/Command/App/From/Recommendation/Resolver.php index 174b75f1d..3a98e3630 100644 --- a/src/Command/App/From/Recommendation/Resolver.php +++ b/src/Command/App/From/Recommendation/Resolver.php @@ -36,8 +36,8 @@ final class Resolver * A site inspector. * @param \Acquia\Cli\Command\App\From\Recommendation\Recommendations $recommendations * A set of defined recommendations. These are *all possible* - * recommendations. It is the resolves job to narrow these down by using the - * site inspector to retrieve information about the source site. + * recommendations. It is the resolves job to narrow these down by using + * the site inspector to retrieve information about the source site. */ public function __construct(SiteInspectorInterface $inspector, Recommendations $recommendations) { diff --git a/src/Command/App/From/Safety/ArrayValidationTrait.php b/src/Command/App/From/Safety/ArrayValidationTrait.php index b1a25f172..b5a83dbf0 100644 --- a/src/Command/App/From/Safety/ArrayValidationTrait.php +++ b/src/Command/App/From/Safety/ArrayValidationTrait.php @@ -34,8 +34,8 @@ protected static function schema(array $schema, array $defaults = []): Structure * The schema definition for the array to be validated. * @param callable $conditional * A callable which receives the context array and returns TRUE if the - * schema should be applied, or FALSE otherwise. If FALSE, the element will - * be omitted from the final validated array. + * schema should be applied, or FALSE otherwise. If FALSE, the element + * will be omitted from the final validated array. * @param array $defaults * Defaults for the array to be validated. * @return \Acquia\Cli\Command\App\From\Safety\StructuredArrayValidator @@ -60,7 +60,8 @@ protected static function listOf(callable $item_validator): Closure } /** - * Creates a validator for an associative array with arbitrary string as keys. + * Creates a validator for an associative array with arbitrary string as + * keys. * * @param callable $entry_validator * A validator to apply to each entry in a validated array. diff --git a/src/Command/App/From/Safety/StructuredArrayValidator.php b/src/Command/App/From/Safety/StructuredArrayValidator.php index b726c2d1a..751569ed3 100644 --- a/src/Command/App/From/Safety/StructuredArrayValidator.php +++ b/src/Command/App/From/Safety/StructuredArrayValidator.php @@ -14,7 +14,8 @@ final class StructuredArrayValidator { /** - * Schema definition key that matches an associative array w/ arbitrary keys. + * Schema definition key that matches an associative array w/ arbitrary + * keys. */ protected const KEYS_ARE_STRINGS = __CLASS__ . '%array_keys_are_string%'; @@ -102,8 +103,8 @@ public static function createConditionalValidator(array $schema, Closure $condit * @param mixed $arr * An array to validate. * @return array - * If the given $arr is valid, the given $arr value. Array keys not defined - * in the schema definition will be stripped from return value. + * If the given $arr is valid, the given $arr value. Array keys not + * defined in the schema definition will be stripped from return value. */ public function __invoke(mixed $arr): array { @@ -157,8 +158,8 @@ public function isValid(mixed $arr): bool * Whether the validator is conditional. * * @return bool - * TRUE if the validator may or not be applied, depending on context. FALSE - * if the validator will be applied unconditionally. + * TRUE if the validator may or not be applied, depending on context. + * FALSE if the validator will be applied unconditionally. */ public function isConditional(): bool { diff --git a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php index 1a1e72c80..1efebb90a 100644 --- a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php +++ b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php @@ -51,7 +51,7 @@ protected function readExtensions(): array // Special case to remove 'standard' from the module's list. unset($enabled['standard']); $modules = array_values(array_map(function (string $name) use ($enabled) { - // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys + // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys return (object) [ 'name' => $name, 'status' => true, @@ -59,9 +59,12 @@ protected function readExtensions(): array 'humanName' => $enabled[$name]->info['name'], 'version' => $enabled[$name]->info['version'], ]; - // phpcs:enable + // phpcs:enable }, array_keys($enabled))); - return array_map([Drupal7Extension::class, 'createFromStdClass'], $modules); + return array_map([ + Drupal7Extension::class, + 'createFromStdClass', + ], $modules); } public function getPublicFilePath(): string @@ -98,7 +101,7 @@ protected function bootstrap(): void $_SERVER['REQUEST_URI'] = $this->uri . '/'; $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] . 'index.php'; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - $_SERVER['REQUEST_METHOD'] = 'GET'; + $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['SERVER_SOFTWARE'] = null; $_SERVER['HTTP_USER_AGENT'] = 'console'; $_SERVER['SCRIPT_FILENAME'] = DRUPAL_ROOT . '/index.php'; diff --git a/src/Command/App/From/SourceSite/SiteInspectorInterface.php b/src/Command/App/From/SourceSite/SiteInspectorInterface.php index 98181799c..84d2b9f48 100644 --- a/src/Command/App/From/SourceSite/SiteInspectorInterface.php +++ b/src/Command/App/From/SourceSite/SiteInspectorInterface.php @@ -15,18 +15,21 @@ interface SiteInspectorInterface * @see \Acquia\Cli\Command\App\From\SourceSite\SiteInspectorInterface::getExtensions() */ public const FLAG_EXTENSION_DISABLED = 1 << 1; + /** * Flag adding themes. * * @see \Acquia\Cli\Command\App\From\SourceSite\SiteInspectorInterface::getExtensions() */ public const FLAG_EXTENSION_THEME = 1 << 3; + /** * Flag adding modules. * * @see \Acquia\Cli\Command\App\From\SourceSite\SiteInspectorInterface::getExtensions() */ public const FLAG_EXTENSION_MODULE = 1 << 2; + /** * Flag adding enabled extensions. * @@ -39,11 +42,11 @@ interface SiteInspectorInterface * * @param int $flags * Bitwise flags indicting various subsets of extensions to be returned. - * Omitting flags omits those extensions from the return value. I.e. if the - * FLAG_EXTENSION_ENABLED flag is given, but not the FLAG_EXTENSION_DISABLED - * flag, then only enabled extensions will be returned. In the example - * below, all enabled modules will be returned. Themes and disabled modules - * will be excluded. + * Omitting flags omits those extensions from the return value. I.e. if + * the FLAG_EXTENSION_ENABLED flag is given, but not the + * FLAG_EXTENSION_DISABLED flag, then only enabled extensions will be + * returned. In the example below, all enabled modules will be + * returned. Themes and disabled modules will be excluded. * @code * $inspector->getExtensions(Drupal7SiteInspector::FLAG_EXTENSION_ENABLED|Drupal7SiteInspector::FLAG_EXTENSION_MODULE); * @endcode diff --git a/src/Command/App/LogTailCommand.php b/src/Command/App/LogTailCommand.php index 5fd9cf648..9109c1aff 100644 --- a/src/Command/App/LogTailCommand.php +++ b/src/Command/App/LogTailCommand.php @@ -22,7 +22,10 @@ use Symfony\Component\Console\Output\OutputInterface; #[RequireAuth] -#[AsCommand(name: 'app:log:tail', description: 'Tail the logs from your environments', aliases: ['tail', 'log:tail'])] +#[AsCommand(name: 'app:log:tail', description: 'Tail the logs from your environments', aliases: [ + 'tail', + 'log:tail', +])] final class LogTailCommand extends CommandBase { public function __construct( @@ -44,7 +47,7 @@ public function __construct( protected function configure(): void { $this - ->acceptEnvironmentId(); + ->acceptEnvironmentId(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/App/NewCommand.php b/src/Command/App/NewCommand.php index 9f53f723a..46552d2d2 100644 --- a/src/Command/App/NewCommand.php +++ b/src/Command/App/NewCommand.php @@ -20,7 +20,7 @@ final class NewCommand extends CommandBase protected function configure(): void { $this - ->addArgument('directory', InputArgument::OPTIONAL, 'The destination directory'); + ->addArgument('directory', InputArgument::OPTIONAL, 'The destination directory'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -93,7 +93,10 @@ private function createDrupalProject(string $project, string $dir): void private function initializeGitRepository(string $dir): void { - if ($this->localMachineHelper->getFilesystem()->exists(Path::join($dir, '.git'))) { + if ( + $this->localMachineHelper->getFilesystem() + ->exists(Path::join($dir, '.git')) + ) { $this->logger->debug('.git directory detected, skipping Git repo initialization'); return; } diff --git a/src/Command/App/NewFromDrupal7Command.php b/src/Command/App/NewFromDrupal7Command.php index 41669d226..0769250aa 100644 --- a/src/Command/App/NewFromDrupal7Command.php +++ b/src/Command/App/NewFromDrupal7Command.php @@ -23,9 +23,9 @@ use Symfony\Component\Validator\Exception\ValidatorException; #[AsCommand(name: 'app:new:from:drupal7', description: 'Generate a new Drupal 9+ project from a Drupal 7 application using the default Acquia Migrate Accelerate recommendations.', aliases: [ - // Currently only "from Drupal 7", more to potentially follow. + // Currently only "from Drupal 7", more to potentially follow. 'from:d7', - // A nod to its roots. + // A nod to its roots. 'ama', ])] final class NewFromDrupal7Command extends CommandBase @@ -41,19 +41,19 @@ final class NewFromDrupal7Command extends CommandBase /** * Exit code raised when a Drupal 7 installation cannot be determined. * - * This indicates the --drupal7-uri was not given and a sane default site could not be - * determined. + * This indicates the --drupal7-uri was not given and a sane default site + * could not be determined. */ public const ERR_INDETERMINATE_SITE = 4; protected function configure(): void { $this - ->addOption('drupal7-directory', 'source', InputOption::VALUE_OPTIONAL, 'The root of the Drupal 7 application') - ->addOption('drupal7-uri', 'uri', InputOption::VALUE_OPTIONAL, 'Only necessary in case of a multisite. If a single site, this will be computed automatically.') - ->addOption('stored-analysis', 'analysis', InputOption::VALUE_OPTIONAL, 'As an alternative to drupal7-directory, it is possible to pass a stored analysis.') - ->addOption('recommendations', 'recommendations', InputOption::VALUE_OPTIONAL, 'Overrides the default recommendations.') - ->addOption('directory', 'destination', InputOption::VALUE_OPTIONAL, 'The directory where to generate the new application.'); + ->addOption('drupal7-directory', 'source', InputOption::VALUE_OPTIONAL, 'The root of the Drupal 7 application') + ->addOption('drupal7-uri', 'uri', InputOption::VALUE_OPTIONAL, 'Only necessary in case of a multisite. If a single site, this will be computed automatically.') + ->addOption('stored-analysis', 'analysis', InputOption::VALUE_OPTIONAL, 'As an alternative to drupal7-directory, it is possible to pass a stored analysis.') + ->addOption('recommendations', 'recommendations', InputOption::VALUE_OPTIONAL, 'Overrides the default recommendations.') + ->addOption('directory', 'destination', InputOption::VALUE_OPTIONAL, 'The directory where to generate the new application.'); } private function getInspector(InputInterface $input): SiteInspectorInterface @@ -114,8 +114,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $extensions = $inspector->getExtensions(SiteInspectorInterface::FLAG_EXTENSION_MODULE | SiteInspectorInterface::FLAG_EXTENSION_ENABLED); $module_count = count($extensions); $system_module_version = array_reduce( - array_filter($extensions, fn (ExtensionInterface $extension) => $extension->isModule() && $extension->getName() === 'system'), - fn (mixed $carry, ExtensionInterface $extension) => $extension->getVersion() + array_filter($extensions, fn(ExtensionInterface $extension) => $extension->isModule() && $extension->getName() === 'system'), + fn(mixed $carry, ExtensionInterface $extension) => $extension->getVersion() ); $site_location = property_exists($inspector, 'uri') ? 'sites/' . $inspector->uri : ''; $output->writeln(sprintf("👍 Found Drupal 7 site (%s to be precise) at %s, with %d modules enabled!", $system_module_version, $site_location, $module_count)); @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $results = $project_builder->buildProject(); $unique_patch_count = array_reduce( $results['rootPackageDefinition']['extra']['patches'], - fn (array $unique_patches, array $patches) => array_unique(array_merge($unique_patches, array_values($patches))), + fn(array $unique_patches, array $patches) => array_unique(array_merge($unique_patches, array_values($patches))), [] ); $output->writeln(sprintf( @@ -218,7 +218,10 @@ function (mixed $path): string { private function initializeGitRepository(string $dir): void { - if ($this->localMachineHelper->getFilesystem()->exists(Path::join($dir, '.git'))) { + if ( + $this->localMachineHelper->getFilesystem() + ->exists(Path::join($dir, '.git')) + ) { $this->logger->debug('.git directory detected, skipping Git repo initialization'); return; } diff --git a/src/Command/App/TaskWaitCommand.php b/src/Command/App/TaskWaitCommand.php index 4c0585720..442564de5 100644 --- a/src/Command/App/TaskWaitCommand.php +++ b/src/Command/App/TaskWaitCommand.php @@ -19,9 +19,9 @@ final class TaskWaitCommand extends CommandBase protected function configure(): void { $this - ->addArgument('notification-uuid', InputArgument::REQUIRED, 'The task notification UUID or Cloud Platform API response containing a linked notification') - ->setHelp('Accepts either a notification UUID or Cloud Platform API response as JSON string. The JSON string must contain the _links->notification->href property.') - ->addUsage('"$(acli api:environments:domain-clear-caches [environmentId] [domain])"'); + ->addArgument('notification-uuid', InputArgument::REQUIRED, 'The task notification UUID or Cloud Platform API response containing a linked notification') + ->setHelp('Accepts either a notification UUID or Cloud Platform API response as JSON string. The JSON string must contain the _links->notification->href property.') + ->addUsage('"$(acli api:environments:domain-clear-caches [environmentId] [domain])"'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Archive/ArchiveExportCommand.php b/src/Command/Archive/ArchiveExportCommand.php index 46a786d7e..8fca0966a 100644 --- a/src/Command/Archive/ArchiveExportCommand.php +++ b/src/Command/Archive/ArchiveExportCommand.php @@ -39,10 +39,10 @@ final class ArchiveExportCommand extends CommandBase protected function configure(): void { $this - ->addArgument('destination-dir', InputArgument::REQUIRED, 'The destination directory for the archive file') - ->addOption('source-dir', 'dir', InputOption::VALUE_REQUIRED, 'The directory containing the Drupal project to be pushed') - ->addOption('no-files', null, InputOption::VALUE_NONE, 'Exclude public files directory from archive') - ->addOption('no-database', 'no-db', InputOption::VALUE_NONE, 'Exclude database dump from archive'); + ->addArgument('destination-dir', InputArgument::REQUIRED, 'The destination directory for the archive file') + ->addOption('source-dir', 'dir', InputOption::VALUE_REQUIRED, 'The directory containing the Drupal project to be pushed') + ->addOption('no-files', null, InputOption::VALUE_NONE, 'Exclude public files directory from archive') + ->addOption('no-database', 'no-db', InputOption::VALUE_NONE, 'Exclude database dump from archive'); } protected function initialize(InputInterface $input, OutputInterface $output): void @@ -110,17 +110,21 @@ private function createArchiveDirectory(string $artifactDir): void $this->checklist->updateProgressBar("Mirroring source files from {$this->dir} to {$artifactDir}"); $originFinder = $this->localMachineHelper->getFinder(); $originFinder->files()->in($this->dir) - // Include dot files like .htaccess. - ->ignoreDotFiles(false) - // If .gitignore exists, ignore VCS files like vendor. - ->ignoreVCSIgnored(file_exists(Path::join($this->dir, '.gitignore'))); + // Include dot files like .htaccess. + ->ignoreDotFiles(false) + // If .gitignore exists, ignore VCS files like vendor. + ->ignoreVCSIgnored(file_exists(Path::join($this->dir, '.gitignore'))); if ($this->input->getOption('no-files')) { $this->checklist->updateProgressBar('Skipping ' . self::PUBLIC_FILES_DIR); $originFinder->exclude([self::PUBLIC_FILES_DIR]); } $targetFinder = $this->localMachineHelper->getFinder(); $targetFinder->files()->in($artifactDir)->ignoreDotFiles(false); - $this->localMachineHelper->getFilesystem()->mirror($this->dir, $artifactDir, $originFinder, ['override' => true, 'delete' => true], $targetFinder); + $this->localMachineHelper->getFilesystem() + ->mirror($this->dir, $artifactDir, $originFinder, [ + 'delete' => true, + 'override' => true, + ], $targetFinder); } private function exportDatabaseToArchiveDir( @@ -147,7 +151,14 @@ private function compressArchiveDirectory(string $archiveDir, string|bool|array| $destinationFilename = basename($archiveDir) . '.tar.gz'; $destinationFilepath = Path::join($destinationDir, $destinationFilename); $this->localMachineHelper->checkRequiredBinariesExist(['tar']); - $process = $this->localMachineHelper->execute(['tar', '-zcvf', $destinationFilepath, '--directory', $archiveDir, '.'], $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $process = $this->localMachineHelper->execute([ + 'tar', + '-zcvf', + $destinationFilepath, + '--directory', + $archiveDir, + '.', + ], $outputCallback, null, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException('Unable to create tarball: {message}', ['message' => $process->getErrorOutput()]); } diff --git a/src/Command/Auth/AuthAcsfLoginCommand.php b/src/Command/Auth/AuthAcsfLoginCommand.php index bedc80732..3011e9b34 100644 --- a/src/Command/Auth/AuthAcsfLoginCommand.php +++ b/src/Command/Auth/AuthAcsfLoginCommand.php @@ -17,9 +17,9 @@ final class AuthAcsfLoginCommand extends CommandBase protected function configure(): void { $this - ->addOption('username', 'u', InputOption::VALUE_REQUIRED, "Your Site Factory username") - ->addOption('key', 'k', InputOption::VALUE_REQUIRED, "Your Site Factory key") - ->addOption('factory-url', 'f', InputOption::VALUE_REQUIRED, "Your Site Factory URL (including https://)"); + ->addOption('username', 'u', InputOption::VALUE_REQUIRED, "Your Site Factory username") + ->addOption('key', 'k', InputOption::VALUE_REQUIRED, "Your Site Factory key") + ->addOption('factory-url', 'f', InputOption::VALUE_REQUIRED, "Your Site Factory URL (including https://)"); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Auth/AuthLoginCommand.php b/src/Command/Auth/AuthLoginCommand.php index 4645c934d..098598fa1 100644 --- a/src/Command/Auth/AuthLoginCommand.php +++ b/src/Command/Auth/AuthLoginCommand.php @@ -18,9 +18,9 @@ final class AuthLoginCommand extends CommandBase protected function configure(): void { $this - ->addOption('key', 'k', InputOption::VALUE_REQUIRED, 'Your Cloud Platform API key') - ->addOption('secret', 's', InputOption::VALUE_REQUIRED, 'Your Cloud Platform API secret') - ->setHelp('Acquia CLI can store multiple sets of credentials in case you have multiple Cloud Platform accounts. However, only a single account can be active at a time. This command allows you to activate a new or existing set of credentials.'); + ->addOption('key', 'k', InputOption::VALUE_REQUIRED, 'Your Cloud Platform API key') + ->addOption('secret', 's', InputOption::VALUE_REQUIRED, 'Your Cloud Platform API secret') + ->setHelp('Acquia CLI can store multiple sets of credentials in case you have multiple Cloud Platform accounts. However, only a single account can be active at a time. This command allows you to activate a new or existing set of credentials.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/CodeStudio/CodeStudioCiCdVariables.php b/src/Command/CodeStudio/CodeStudioCiCdVariables.php index c57734a56..3b91e40f0 100644 --- a/src/Command/CodeStudio/CodeStudioCiCdVariables.php +++ b/src/Command/CodeStudio/CodeStudioCiCdVariables.php @@ -16,8 +16,8 @@ public static function getList(): array } /** - * @return array - */ + * @return array + */ public static function getDefaultsForNode(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $nodeVersion = null): array { return [ @@ -67,8 +67,8 @@ public static function getDefaultsForNode(?string $cloudApplicationUuid = null, } /** - * @return array - */ + * @return array + */ public static function getDefaultsForPhp(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $phpVersion = null): array { return [ diff --git a/src/Command/CodeStudio/CodeStudioCommandTrait.php b/src/Command/CodeStudio/CodeStudioCommandTrait.php index 44a81691d..170cc1dae 100644 --- a/src/Command/CodeStudio/CodeStudioCommandTrait.php +++ b/src/Command/CodeStudio/CodeStudioCommandTrait.php @@ -173,7 +173,8 @@ private function determineGitLabProject(ApplicationResponse $cloudApplication): return $this->gitLabClient->projects()->show($id); } // Search for existing project that matches expected description pattern. - $projects = $this->gitLabClient->projects()->all(['search' => $cloudApplication->uuid]); + $projects = $this->gitLabClient->projects() + ->all(['search' => $cloudApplication->uuid]); if ($projects) { if (count($projects) == 1) { return reset($projects); @@ -216,17 +217,19 @@ private function createGitLabProject(ApplicationResponse $cloudApplication): arr ]); $parameters = $this->getGitLabProjectDefaults(); if ($userGroups) { - $userGroups[] = $this->gitLabClient->namespaces()->show($this->gitLabAccount['username']); + $userGroups[] = $this->gitLabClient->namespaces() + ->show($this->gitLabAccount['username']); $projectGroup = $this->promptChooseFromObjectsOrArrays($userGroups, 'id', 'path', 'Choose which group this new project should belong to:'); $parameters['namespace_id'] = $projectGroup['id']; } $slugger = new AsciiSlugger(); $projectName = (string) $slugger->slug($cloudApplication->name); - $project = $this->gitLabClient->projects()->create($projectName, $parameters); + $project = $this->gitLabClient->projects() + ->create($projectName, $parameters); try { $this->gitLabClient->projects() - ->uploadAvatar($project['id'], __DIR__ . '/drupal_icon.png'); + ->uploadAvatar($project['id'], __DIR__ . '/drupal_icon.png'); } catch (ValidationFailedException) { $this->io->warning("Failed to upload project avatar"); } @@ -262,8 +265,8 @@ private function getGitLabProjectDefaults(): array private function acceptGitlabOptions(): static { $this->addOption('gitlab-token', null, InputOption::VALUE_REQUIRED, 'The GitLab personal access token that will be used to communicate with the GitLab instance') - ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.') - ->addOption('gitlab-host-name', null, InputOption::VALUE_REQUIRED, 'The GitLab hostname.'); + ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.') + ->addOption('gitlab-host-name', null, InputOption::VALUE_REQUIRED, 'The GitLab hostname.'); return $this; } } diff --git a/src/Command/CodeStudio/CodeStudioPhpVersionCommand.php b/src/Command/CodeStudio/CodeStudioPhpVersionCommand.php index 537ffcc71..9a6a0c155 100644 --- a/src/Command/CodeStudio/CodeStudioPhpVersionCommand.php +++ b/src/Command/CodeStudio/CodeStudioPhpVersionCommand.php @@ -21,9 +21,9 @@ final class CodeStudioPhpVersionCommand extends CommandBase protected function configure(): void { $this - ->addArgument('php-version', InputArgument::REQUIRED, 'The PHP version that needs to configured or updated') - ->addUsage('8.1 myapp') - ->addUsage('8.1 abcd1234-1111-2222-3333-0e02b2c3d470'); + ->addArgument('php-version', InputArgument::REQUIRED, 'The PHP version that needs to configured or updated') + ->addUsage('8.1 myapp') + ->addUsage('8.1 abcd1234-1111-2222-3333-0e02b2c3d470'); $this->acceptApplicationUuid(); $this->acceptGitlabOptions(); } @@ -48,17 +48,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $phpVersionAlreadySet = false; // Get all variables of the project. - $allProjectVariables = $this->gitLabClient->projects()->variables($project['id']); + $allProjectVariables = $this->gitLabClient->projects() + ->variables($project['id']); if (!empty($allProjectVariables)) { $variables = array_column($allProjectVariables, 'value', 'key'); $phpVersionAlreadySet = $variables['PHP_VERSION'] ?? false; } // If PHP version is not set in variables. if (!$phpVersionAlreadySet) { - $this->gitLabClient->projects()->addVariable($project['id'], 'PHP_VERSION', $phpVersion); + $this->gitLabClient->projects() + ->addVariable($project['id'], 'PHP_VERSION', $phpVersion); } else { // If variable already exists, updating the variable. - $this->gitLabClient->projects()->updateVariable($project['id'], 'PHP_VERSION', $phpVersion); + $this->gitLabClient->projects() + ->updateVariable($project['id'], 'PHP_VERSION', $phpVersion); } } catch (RuntimeException) { $this->io->error("Unable to update the PHP version to $phpVersion"); diff --git a/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php b/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php index 1dcf3aed5..83abdc3b6 100644 --- a/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php +++ b/src/Command/CodeStudio/CodeStudioPipelinesMigrateCommand.php @@ -24,10 +24,10 @@ final class CodeStudioPipelinesMigrateCommand extends CommandBase protected function configure(): void { $this - ->addOption('key', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API token that Code Studio will use') - ->addOption('secret', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API secret that Code Studio will use') - ->addOption('gitlab-token', null, InputOption::VALUE_REQUIRED, 'The GitLab personal access token that will be used to communicate with the GitLab instance') - ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.'); + ->addOption('key', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API token that Code Studio will use') + ->addOption('secret', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API secret that Code Studio will use') + ->addOption('gitlab-token', null, InputOption::VALUE_REQUIRED, 'The GitLab personal access token that will be used to communicate with the GitLab instance') + ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.'); $this->acceptApplicationUuid(); $this->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } @@ -77,12 +77,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * Check whether wizard command is executed by checking the env variable of codestudio project. + * Check whether wizard command is executed by checking the env variable of + * codestudio project. */ private function checkGitLabCiCdVariables(array $project): void { $gitlabCicdVariables = CodeStudioCiCdVariables::getList(); - $gitlabCicdExistingVariables = $this->gitLabClient->projects()->variables($project['id']); + $gitlabCicdExistingVariables = $this->gitLabClient->projects() + ->variables($project['id']); $existingKeys = array_column($gitlabCicdExistingVariables, 'key'); foreach ($gitlabCicdVariables as $gitlabCicdVariable) { if (!in_array($gitlabCicdVariable, $existingKeys, true)) { @@ -92,7 +94,8 @@ private function checkGitLabCiCdVariables(array $project): void } /** - * Check acquia-pipeline.yml file exists in the root repo and remove ci_config_path from codestudio project. + * Check acquia-pipeline.yml file exists in the root repo and remove + * ci_config_path from codestudio project. * * @return array */ @@ -101,11 +104,17 @@ private function getAcquiaPipelinesFileContents(array $project): array $pipelinesFilepathYml = Path::join($this->projectDir, 'acquia-pipelines.yml'); $pipelinesFilepathYaml = Path::join($this->projectDir, 'acquia-pipelines.yaml'); if ( - $this->localMachineHelper->getFilesystem()->exists($pipelinesFilepathYml) || - $this->localMachineHelper->getFilesystem()->exists($pipelinesFilepathYaml) + $this->localMachineHelper->getFilesystem() + ->exists($pipelinesFilepathYml) || + $this->localMachineHelper->getFilesystem() + ->exists($pipelinesFilepathYaml) ) { - $this->gitLabClient->projects()->update($project['id'], ['ci_config_path' => '']); - $pipelinesFilenames = ['acquia-pipelines.yml', 'acquia-pipelines.yaml']; + $this->gitLabClient->projects() + ->update($project['id'], ['ci_config_path' => '']); + $pipelinesFilenames = [ + 'acquia-pipelines.yml', + 'acquia-pipelines.yaml', + ]; foreach ($pipelinesFilenames as $pipelinesFilename) { $pipelinesFilepath = Path::join($this->projectDir, $pipelinesFilename); if (file_exists($pipelinesFilepath)) { @@ -129,7 +138,10 @@ private function getAcquiaPipelinesFileContents(array $project): array private function getGitLabCiFileTemplate(): array { return [ - 'include' => ['project' => 'acquia/standard-template', 'file' => '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'], + 'include' => [ + 'file' => '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml', + 'project' => 'acquia/standard-template', + ], ]; } @@ -188,7 +200,7 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array 'npm run build' => 'Build Drupal', 'validate' => 'Test Drupal', 'tests' => 'Test Drupal', - 'test' => 'Test Drupal', + 'test' => 'Test Drupal', 'npm test' => 'Test Drupal', 'artifact' => 'Deploy Drupal', 'deploy' => 'Deploy Drupal', @@ -249,7 +261,7 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array } if (array_key_exists($scriptName, $codeStudioJobs) && array_key_exists('script', $codeStudioJobs[$scriptName]) && in_array($command, $codeStudioJobs[$scriptName]['script'], true)) { - break; + break; } if (!array_key_exists($scriptName, $eventMap['skip'])) { $codeStudioJobs[$scriptName]['script'][] = $command; @@ -266,7 +278,7 @@ private function migrateEventsSection(array $acquiaPipelinesFileContents, array } } if (!array_key_exists('stage', $codeStudioJobs[$scriptName])) { - $codeStudioJobs[$scriptName]['stage'] = $eventMap['default_stage']; + $codeStudioJobs[$scriptName]['stage'] = $eventMap['default_stage']; } $codeStudioJobs[$scriptName]['needs'] = $eventMap['needs']; } @@ -300,8 +312,10 @@ private function removeEmptyScript(array &$gitlabCiFileContents): void private function createGitLabCiFile(array $contents, string|iterable $acquiaPipelinesFileName): void { $gitlabCiFilepath = Path::join($this->projectDir, '.gitlab-ci.yml'); - $this->localMachineHelper->getFilesystem()->dumpFile($gitlabCiFilepath, Yaml::dump($contents, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); - $this->localMachineHelper->getFilesystem()->remove($acquiaPipelinesFileName); + $this->localMachineHelper->getFilesystem() + ->dumpFile($gitlabCiFilepath, Yaml::dump($contents, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); + $this->localMachineHelper->getFilesystem() + ->remove($acquiaPipelinesFileName); } private function assignStageFromKeywords(array $keywords, string $haystack): ?string diff --git a/src/Command/CodeStudio/CodeStudioWizardCommand.php b/src/Command/CodeStudio/CodeStudioWizardCommand.php index 500d7225b..e49199bbd 100644 --- a/src/Command/CodeStudio/CodeStudioWizardCommand.php +++ b/src/Command/CodeStudio/CodeStudioWizardCommand.php @@ -25,11 +25,11 @@ final class CodeStudioWizardCommand extends WizardCommandBase protected function configure(): void { $this - ->addOption('key', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API token that Code Studio will use') - ->addOption('secret', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API secret that Code Studio will use') - ->addOption('gitlab-token', null, InputOption::VALUE_REQUIRED, 'The GitLab personal access token that will be used to communicate with the GitLab instance') - ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.') - ->addOption('gitlab-host-name', null, InputOption::VALUE_REQUIRED, 'The GitLab hostname.'); + ->addOption('key', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API token that Code Studio will use') + ->addOption('secret', null, InputOption::VALUE_REQUIRED, 'The Cloud Platform API secret that Code Studio will use') + ->addOption('gitlab-token', null, InputOption::VALUE_REQUIRED, 'The GitLab personal access token that will be used to communicate with the GitLab instance') + ->addOption('gitlab-project-id', null, InputOption::VALUE_REQUIRED, 'The project ID (an integer) of the GitLab project to configure.') + ->addOption('gitlab-host-name', null, InputOption::VALUE_REQUIRED, 'The GitLab hostname.'); $this->acceptApplicationUuid(); } @@ -83,15 +83,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int $account, [ "deploy to non-prod", - // Add SSH key to git repository. + // Add SSH key to git repository. "add ssh key to git", - // Add SSH key to non-production environments. + // Add SSH key to non-production environments. "add ssh key to non-prod", - // Add a CD environment. + // Add a CD environment. "add an environment", - // Delete a CD environment. + // Delete a CD environment. "delete an environment", - // Manage environment variables on a non-production environment. + // Manage environment variables on a non-production environment. "administer environment variables on non-prod", ] ); @@ -152,7 +152,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ private function getGitLabScheduleByDescription(array $project, string $scheduledPipelineDescription): ?array { - $existingSchedules = $this->gitLabClient->schedules()->showAll($project['id']); + $existingSchedules = $this->gitLabClient->schedules() + ->showAll($project['id']); foreach ($existingSchedules as $schedule) { if ($schedule['description'] == $scheduledPipelineDescription) { return $schedule; @@ -166,7 +167,8 @@ private function getGitLabScheduleByDescription(array $project, string $schedule */ private function getGitLabProjectAccessTokenByName(array $project, string $name): ?array { - $existingProjectAccessTokens = $this->gitLabClient->projects()->projectAccessTokens($project['id']); + $existingProjectAccessTokens = $this->gitLabClient->projects() + ->projectAccessTokens($project['id']); foreach ($existingProjectAccessTokens as $key => $token) { if ($token['name'] == $name) { return $token; @@ -194,16 +196,16 @@ private function createProjectAccessToken(array $project, string $projectAccessT if ($existingToken = $this->getGitLabProjectAccessTokenByName($project, $projectAccessTokenName)) { $this->checklist->addItem("Deleting access token named $projectAccessTokenName"); $this->gitLabClient->projects() - ->deleteProjectAccessToken($project['id'], $existingToken['id']); + ->deleteProjectAccessToken($project['id'], $existingToken['id']); $this->checklist->completePreviousItem(); } $this->checklist->addItem("Creating access token named $projectAccessTokenName"); $projectAccessToken = $this->gitLabClient->projects() - ->createProjectAccessToken($project['id'], [ - 'expires_at' => new DateTime('+365 days'), - 'name' => $projectAccessTokenName, - 'scopes' => ['api', 'write_repository'], - ]); + ->createProjectAccessToken($project['id'], [ + 'expires_at' => new DateTime('+365 days'), + 'name' => $projectAccessTokenName, + 'scopes' => ['api', 'write_repository'], + ]); $this->checklist->completePreviousItem(); return $projectAccessToken['token']; } @@ -213,7 +215,7 @@ private function setGitLabCiCdVariablesForPhpProject(array $project, string $clo $this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}.."); $gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForPhp($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion); $gitlabCicdExistingVariables = $this->gitLabClient->projects() - ->variables($project['id']); + ->variables($project['id']); $gitlabCicdExistingVariablesKeyed = []; foreach ($gitlabCicdExistingVariables as $variable) { $key = $variable['key']; @@ -224,10 +226,16 @@ private function setGitLabCiCdVariablesForPhpProject(array $project, string $clo $this->checklist->addItem("Setting GitLab CI/CD variables for {$variable['key']}"); if (!array_key_exists($variable['key'], $gitlabCicdExistingVariablesKeyed)) { $this->gitLabClient->projects() - ->addVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]); + ->addVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, [ + 'masked' => $variable['masked'], + 'variable_type' => $variable['variable_type'], + ]); } else { $this->gitLabClient->projects() - ->updateVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]); + ->updateVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, [ + 'masked' => $variable['masked'], + 'variable_type' => $variable['variable_type'], + ]); } $this->checklist->completePreviousItem(); } @@ -238,7 +246,7 @@ private function setGitLabCiCdVariablesForNodeProject(array $project, string $cl $this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}.."); $gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion); $gitlabCicdExistingVariables = $this->gitLabClient->projects() - ->variables($project['id']); + ->variables($project['id']); $gitlabCicdExistingVariablesKeyed = []; foreach ($gitlabCicdExistingVariables as $variable) { $key = $variable['key']; @@ -249,10 +257,16 @@ private function setGitLabCiCdVariablesForNodeProject(array $project, string $cl $this->checklist->addItem("Setting CI/CD variable {$variable['key']}"); if (!array_key_exists($variable['key'], $gitlabCicdExistingVariablesKeyed)) { $this->gitLabClient->projects() - ->addVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]); + ->addVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, [ + 'masked' => $variable['masked'], + 'variable_type' => $variable['variable_type'], + ]); } else { $this->gitLabClient->projects() - ->updateVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]); + ->updateVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], null, [ + 'masked' => $variable['masked'], + 'variable_type' => $variable['variable_type'], + ]); } $this->checklist->completePreviousItem(); } @@ -265,20 +279,23 @@ private function createScheduledPipeline(array $project): void if (!$this->getGitLabScheduleByDescription($project, $scheduledPipelineDescription)) { $this->checklist->addItem("Creating scheduled pipeline $scheduledPipelineDescription"); - $pipeline = $this->gitLabClient->schedules()->create($project['id'], [ - // Every Thursday at midnight. - 'cron' => '0 0 * * 4', - 'description' => $scheduledPipelineDescription, - 'ref' => $project['default_branch'], - ]); - $this->gitLabClient->schedules()->addVariable($project['id'], $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', - 'value' => 'true', - ]); - $this->gitLabClient->schedules()->addVariable($project['id'], $pipeline['id'], [ - 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', - 'value' => 'true', - ]); + $pipeline = $this->gitLabClient->schedules() + ->create($project['id'], [ + // Every Thursday at midnight. + 'cron' => '0 0 * * 4', + 'description' => $scheduledPipelineDescription, + 'ref' => $project['default_branch'], + ]); + $this->gitLabClient->schedules() + ->addVariable($project['id'], $pipeline['id'], [ + 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', + 'value' => 'true', + ]); + $this->gitLabClient->schedules() + ->addVariable($project['id'], $pipeline['id'], [ + 'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE', + 'value' => 'true', + ]); } else { $this->checklist->addItem("Scheduled pipeline named $scheduledPipelineDescription already exists"); } @@ -289,9 +306,11 @@ private function updateGitLabProject(array $project): void { // Setting the description to match the known pattern will allow us to automatically find the project next time. if ($project['description'] !== $this->gitLabProjectDescription) { - $this->gitLabClient->projects()->update($project['id'], $this->getGitLabProjectDefaults()); + $this->gitLabClient->projects() + ->update($project['id'], $this->getGitLabProjectDefaults()); try { - $this->gitLabClient->projects()->uploadAvatar($project['id'], __DIR__ . '/drupal_icon.png'); + $this->gitLabClient->projects() + ->uploadAvatar($project['id'], __DIR__ . '/drupal_icon.png'); } catch (ValidationFailedException) { $this->io->warning("Failed to upload project avatar"); } diff --git a/src/Command/CommandBase.php b/src/Command/CommandBase.php index 0231b8746..70e64e3d0 100644 --- a/src/Command/CommandBase.php +++ b/src/Command/CommandBase.php @@ -86,15 +86,23 @@ abstract class CommandBase extends Command implements LoggerAwareInterface protected OutputInterface $output; protected SymfonyStyle $io; + protected FormatterHelper $formatter; + private ApplicationResponse $cloudApplication; protected string $dir; + protected string $localDbUser = 'drupal'; + protected string $localDbPassword = 'drupal'; + protected string $localDbName = 'drupal'; + protected string $localDbHost = 'localhost'; + protected bool $drushHasActiveDatabaseConnection; + protected \GuzzleHttp\Client $updateClient; public function __construct( @@ -120,7 +128,7 @@ public function __construct( } if ((new \ReflectionClass(static::class))->getAttributes(RequireDb::class)) { $this->appendHelp('This command requires an active database connection. Set the following environment variables prior to running this command: ' - . 'ACLI_DB_HOST, ACLI_DB_NAME, ACLI_DB_USER, ACLI_DB_PASSWORD'); + . 'ACLI_DB_HOST, ACLI_DB_NAME, ACLI_DB_USER, ACLI_DB_PASSWORD'); } } @@ -212,7 +220,8 @@ protected function initialize(InputInterface $input, OutputInterface $output): v ); $this->formatter = $this->getHelper('formatter'); - $this->output->writeln('Acquia CLI version: ' . $this->getApplication()->getVersion(), OutputInterface::VERBOSITY_DEBUG); + $this->output->writeln('Acquia CLI version: ' . $this->getApplication() + ->getVersion(), OutputInterface::VERBOSITY_DEBUG); if (getenv('ACLI_NO_TELEMETRY') !== 'true') { $this->checkAndPromptTelemetryPreference(); $this->telemetryHelper->initialize(); @@ -260,7 +269,12 @@ public function checkAndPromptTelemetryPreference(): void public function run(InputInterface $input, OutputInterface $output): int { $exitCode = parent::run($input, $output); - if ($exitCode === 0 && in_array($input->getFirstArgument(), ['self-update', 'update'])) { + if ( + $exitCode === 0 && in_array($input->getFirstArgument(), [ + 'self-update', + 'update', + ]) + ) { // Exit immediately to avoid loading additional classes breaking updates. // @see https://github.com/acquia/cli/issues/218 return $exitCode; @@ -285,10 +299,10 @@ public function run(InputInterface $input, OutputInterface $output): int protected function acceptApplicationUuid(): static { $this->addArgument('applicationUuid', InputArgument::OPTIONAL, 'The Cloud Platform application UUID or alias (i.e. an application name optionally prefixed with the realm)') - ->addUsage('[]') - ->addUsage('myapp') - ->addUsage('prod:myapp') - ->addUsage('abcd1234-1111-2222-3333-0e02b2c3d470'); + ->addUsage('[]') + ->addUsage('myapp') + ->addUsage('prod:myapp') + ->addUsage('abcd1234-1111-2222-3333-0e02b2c3d470'); return $this; } @@ -299,10 +313,10 @@ protected function acceptApplicationUuid(): static protected function acceptEnvironmentId(): static { $this->addArgument('environmentId', InputArgument::OPTIONAL, 'The Cloud Platform environment ID or alias (i.e. an application and environment name optionally prefixed with the realm)') - ->addUsage('[]') - ->addUsage('myapp.dev') - ->addUsage('prod:myapp.dev') - ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); + ->addUsage('[]') + ->addUsage('myapp.dev') + ->addUsage('prod:myapp.dev') + ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); return $this; } @@ -310,7 +324,8 @@ protected function acceptEnvironmentId(): static /** * Add site argument. * - * Only call this after acceptEnvironmentId() to keep arguments in the expected order. + * Only call this after acceptEnvironmentId() to keep arguments in the + * expected order. * * @return $this */ @@ -318,7 +333,7 @@ protected function acceptSite(): self { // Do not set a default site in order to force a user prompt. $this->addArgument('site', InputArgument::OPTIONAL, 'For a multisite application, the directory name of the site') - ->addUsage('myapp.dev default'); + ->addUsage('myapp.dev default'); return $this; } @@ -366,7 +381,8 @@ private function promptChooseApplication( } /** - * Prompts the user to choose from a list of environments for a given Cloud Platform application. + * Prompts the user to choose from a list of environments for a given Cloud + * Platform application. */ private function promptChooseEnvironment( Client $acquiaCloudClient, @@ -386,7 +402,8 @@ private function promptChooseEnvironment( } /** - * Prompts the user to choose from a list of logs for a given Cloud Platform environment. + * Prompts the user to choose from a list of logs for a given Cloud + * Platform environment. */ protected function promptChooseLogs(): object|array|null { @@ -408,11 +425,13 @@ protected function promptChooseLogs(): object|array|null /** * Prompt a user to choose from a list. * - * The list is generated from an array of objects. The objects much have at least one unique property and one - * property that can be used as a human-readable label. + * The list is generated from an array of objects. The objects much have at + * least one unique property and one property that can be used as a + * human-readable label. * * @param array[]|object[] $items An array of objects or arrays. - * @param string $uniqueProperty The property of the $item that will be used to identify the object. + * @param string $uniqueProperty The property of the $item that will be + * used to identify the object. */ protected function promptChooseFromObjectsOrArrays(array|ArrayObject $items, string $uniqueProperty, string $labelProperty, string $questionText, bool $multiselect = false): object|array|null { @@ -447,7 +466,7 @@ protected function promptChooseFromObjectsOrArrays(array|ArrayObject $items, str foreach ($items as $item) { if (is_array($item)) { if ($item[$uniqueProperty] === $identifier) { - $chosen[] = $item; + $chosen[] = $item; } } elseif ($item->$uniqueProperty === $identifier) { $chosen[] = $item; @@ -474,12 +493,12 @@ protected function rsyncFiles(string $sourceDir, string $destinationDir, ?callab $this->localMachineHelper->checkRequiredBinariesExist(['rsync']); $command = [ 'rsync', - // -a archive mode; same as -rlptgoD. - // -z compress file data during the transfer. - // -v increase verbosity. - // -P show progress during transfer. - // -h output numbers in a human-readable format. - // -e specify the remote shell to use. + // -a archive mode; same as -rlptgoD. + // -z compress file data during the transfer. + // -v increase verbosity. + // -P show progress during transfer. + // -h output numbers in a human-readable format. + // -e specify the remote shell to use. '-avPhze', 'ssh -o StrictHostKeyChecking=no', $sourceDir . '/', @@ -780,10 +799,11 @@ private function searchApplicationEnvironmentsForGitUrl( } /** - * Infer which Cloud Platform application is associated with the current local git repository. + * Infer which Cloud Platform application is associated with the current + * local git repository. * - * If the local git repository has a remote with a URL that matches a Cloud Platform application's VCS URL, assume - * that we have a match. + * If the local git repository has a remote with a URL that matches a Cloud + * Platform application's VCS URL, assume that we have a match. */ protected function inferCloudAppFromLocalGitConfig( Client $acquiaCloudClient @@ -1041,7 +1061,10 @@ public static function validateEnvironmentAlias(string $alias): string $violations = Validation::createValidator()->validate($alias, [ new Length(['min' => 5]), new NotBlank(), - new Regex(['pattern' => '/.+\..+/', 'message' => 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]']), + new Regex([ + 'message' => 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]', + 'pattern' => '/.+\..+/', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -1062,9 +1085,10 @@ protected function getEnvironmentFromAliasArg(string $alias): EnvironmentRespons private function getEnvFromAlias(string $alias): EnvironmentResponse { - return self::getAliasCache()->get($alias, function () use ($alias): \AcquiaCloudApi\Response\EnvironmentResponse { - return $this->doGetEnvFromAlias($alias); - }); + return self::getAliasCache() + ->get($alias, function () use ($alias): \AcquiaCloudApi\Response\EnvironmentResponse { + return $this->doGetEnvFromAlias($alias); + }); } private function doGetEnvFromAlias(string $alias): EnvironmentResponse @@ -1090,9 +1114,9 @@ private function doGetEnvFromAlias(string $alias): EnvironmentResponse private function getApplicationFromAlias(string $applicationAlias): mixed { return self::getAliasCache() - ->get($applicationAlias, function () use ($applicationAlias) { - return $this->doGetApplicationFromAlias($applicationAlias); - }); + ->get($applicationAlias, function () use ($applicationAlias) { + return $this->doGetApplicationFromAlias($applicationAlias); + }); } /** @@ -1198,7 +1222,8 @@ protected function hasUpdate(): bool|string { $versionParser = new VersionParser(); // Fail fast on development builds (throw UnexpectedValueException). - $currentVersion = $versionParser->normalize($this->getApplication()->getVersion()); + $currentVersion = $versionParser->normalize($this->getApplication() + ->getVersion()); $client = $this->getUpdateClient(); $response = $client->get('https://api.github.com/repos/acquia/cli/releases'); if ($response->getStatusCode() !== 200) { @@ -1256,7 +1281,11 @@ public function getUpdateClient(): \GuzzleHttp\Client protected function fillMissingRequiredApplicationUuid(InputInterface $input, OutputInterface $output): void { - if ($input->hasArgument('applicationUuid') && !$input->getArgument('applicationUuid') && $this->getDefinition()->getArgument('applicationUuid')->isRequired()) { + if ( + $input->hasArgument('applicationUuid') && !$input->getArgument('applicationUuid') && $this->getDefinition() + ->getArgument('applicationUuid') + ->isRequired() + ) { $output->writeln('Inferring Cloud Application UUID for this command since none was provided...', OutputInterface::VERBOSITY_VERBOSE); if ($applicationUuid = $this->determineCloudApplication()) { $output->writeln("Set application uuid to $applicationUuid", OutputInterface::VERBOSITY_VERBOSE); @@ -1429,7 +1458,10 @@ private function getAcsfSites(EnvironmentResponse $cloudEnvironment): array private function getCloudSites(EnvironmentResponse $cloudEnvironment): array { $sitegroup = self::getSitegroup($cloudEnvironment); - $command = ['ls', $this->getCloudSitesPath($cloudEnvironment, $sitegroup)]; + $command = [ + 'ls', + $this->getCloudSitesPath($cloudEnvironment, $sitegroup), + ]; $process = $this->sshHelper->executeCommand($cloudEnvironment->sshUrl, $command, false); $sites = array_filter(explode("\n", trim($process->getOutput()))); if ($process->isSuccessful() && $sites) { @@ -1570,7 +1602,7 @@ protected function runDrushCacheClear(Closure $outputCallback, Checklist $checkl '--verbose', ], $outputCallback, $this->dir, false); if (!$process->isSuccessful()) { - throw new AcquiaCliException('Unable to rebuild Drupal caches via Drush. {message}', ['message' => $process->getErrorOutput()]); + throw new AcquiaCliException('Unable to rebuild Drupal caches via Drush. {message}', ['message' => $process->getErrorOutput()]); } $checklist->completePreviousItem(); } else { @@ -1590,7 +1622,7 @@ protected function runDrushSqlSanitize(Closure $outputCallback, Checklist $check '--verbose', ], $outputCallback, $this->dir, false); if (!$process->isSuccessful()) { - throw new AcquiaCliException('Unable to sanitize Drupal database via Drush. {message}', ['message' => $process->getErrorOutput()]); + throw new AcquiaCliException('Unable to sanitize Drupal database via Drush. {message}', ['message' => $process->getErrorOutput()]); } $checklist->completePreviousItem(); $this->io->newLine(); @@ -1644,12 +1676,18 @@ protected function getDrushDatabaseConnectionStatus(Closure $outputCallback = nu protected function createMySqlDumpOnLocal(string $dbHost, string $dbUser, string $dbName, string $dbPassword, Closure $outputCallback = null): string { - $this->localMachineHelper->checkRequiredBinariesExist(['mysqldump', 'gzip']); + $this->localMachineHelper->checkRequiredBinariesExist([ + 'mysqldump', + 'gzip', + ]); $filename = "acli-mysql-dump-{$dbName}.sql.gz"; $localTempDir = sys_get_temp_dir(); $localFilepath = $localTempDir . '/' . $filename; $this->logger->debug("Dumping MySQL database to $localFilepath on this machine"); - $this->localMachineHelper->checkRequiredBinariesExist(['mysqldump', 'gzip']); + $this->localMachineHelper->checkRequiredBinariesExist([ + 'mysqldump', + 'gzip', + ]); if ($outputCallback) { $outputCallback('out', "Dumping MySQL database to $localFilepath on this machine"); } @@ -1692,7 +1730,10 @@ private function validateApiKey(mixed $key): string $violations = Validation::createValidator()->validate($key, [ new Length(['min' => 10]), new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), + new Regex([ + 'message' => 'The value may not contain spaces', + 'pattern' => '/^\S*$/', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -1710,8 +1751,8 @@ protected function determineApiSecret(): string * * Default can be passed explicitly, separately from the option default, * because Symfony does not make a distinction between an option value set - * explicitly or by default. In other words, we can't prompt for the value of - * an option that already has a default value. + * explicitly or by default. In other words, we can't prompt for the value + * of an option that already has a default value. */ protected function determineOption(string $optionName, bool $hidden = false, ?Closure $validator = null, ?Closure $normalizer = null, string|bool|null $default = null): string|int|bool|null { @@ -1765,7 +1806,8 @@ protected function determineOption(string $optionName, bool $hidden = false, ?Cl } /** - * Get the first environment for a given Cloud application matching a filter. + * Get the first environment for a given Cloud application matching a + * filter. */ private function getAnyAhEnvironment(string $cloudAppUuid, callable $filter): EnvironmentResponse|false { @@ -1937,8 +1979,14 @@ protected function validatePhpVersion(string $version): string $violations = Validation::createValidator()->validate($version, [ new Length(['min' => 3]), new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), - new Regex(['pattern' => '/[0-9]{1}\.[0-9]{1}/', 'message' => 'The value must be in the format "x.y"']), + new Regex([ + 'message' => 'The value may not contain spaces', + 'pattern' => '/^\S*$/', + ]), + new Regex([ + 'message' => 'The value must be in the format "x.y"', + 'pattern' => '/[0-9]{1}\.[0-9]{1}/', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/DocsCommand.php b/src/Command/DocsCommand.php index d4167c4da..cbca0ff8a 100644 --- a/src/Command/DocsCommand.php +++ b/src/Command/DocsCommand.php @@ -17,8 +17,8 @@ final class DocsCommand extends CommandBase protected function configure(): void { $this - ->addArgument('product', InputArgument::OPTIONAL, 'Acquia Product Name') - ->addUsage('acli'); + ->addArgument('product', InputArgument::OPTIONAL, 'Acquia Product Name') + ->addUsage('acli'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -33,7 +33,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'url' => 'acquia-cms', ], 'Acquia DAM Classic' => [ - 'alias' => ['dam', 'acquia_dam', 'dam_classic', 'acquiadam', 'damclassic'], + 'alias' => [ + 'dam', + 'acquia_dam', + 'dam_classic', + 'acquiadam', + 'damclassic', + ], 'url' => 'dam', ], 'Acquia Migrate Accelerate' => [ @@ -45,7 +51,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'url' => 'blt', ], 'Campaign Factory' => [ - 'alias' => ['campaign-factory', 'campaign_factory', 'campaignfactory'], + 'alias' => [ + 'campaign-factory', + 'campaign_factory', + 'campaignfactory', + ], 'url' => 'campaign-factory', ], 'Campaign Studio' => [ @@ -57,7 +67,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'url' => 'ide', ], 'Cloud Platform' => [ - 'alias' => ['cloud-platform', 'acquiacloud', 'acquia_cloud', 'acquia-cloud', 'cloud'], + 'alias' => [ + 'cloud-platform', + 'acquiacloud', + 'acquia_cloud', + 'acquia-cloud', + 'cloud', + ], 'url' => 'cloud-platform', ], 'Code Studio' => [ diff --git a/src/Command/Email/EmailInfoForSubscriptionCommand.php b/src/Command/Email/EmailInfoForSubscriptionCommand.php index 9f01e51c6..bfbae81d0 100644 --- a/src/Command/Email/EmailInfoForSubscriptionCommand.php +++ b/src/Command/Email/EmailInfoForSubscriptionCommand.php @@ -26,8 +26,8 @@ final class EmailInfoForSubscriptionCommand extends CommandBase protected function configure(): void { $this - ->addArgument('subscriptionUuid', InputArgument::OPTIONAL, 'The subscription UUID whose Platform Email configuration is to be checked.') - ->setHelp('This command lists information related to Platform Email for a subscription, including which domains have been validated, which have not, and which applications have Platform Email domains associated.'); + ->addArgument('subscriptionUuid', InputArgument::OPTIONAL, 'The subscription UUID whose Platform Email configuration is to be checked.') + ->setHelp('This command lists information related to Platform Email for a subscription, including which domains have been validated, which have not, and which applications have Platform Email domains associated.'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -39,8 +39,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $response = $client->request('get', "/subscriptions/$subscription->uuid/domains"); if (count($response)) { - $this->localMachineHelper->getFilesystem()->remove("./subscription-$subscription->uuid-domains"); - $this->localMachineHelper->getFilesystem()->mkdir("./subscription-$subscription->uuid-domains"); + $this->localMachineHelper->getFilesystem() + ->remove("./subscription-$subscription->uuid-domains"); + $this->localMachineHelper->getFilesystem() + ->mkdir("./subscription-$subscription->uuid-domains"); $this->writeDomainsToTables($output, $subscription, $response); @@ -80,7 +82,11 @@ private function writeDomainsToTables(OutputInterface $output, SubscriptionRespo $writerFailedDomains = Writer::createFromPath("./subscription-$subscription->uuid-domains/failed-domains-summary.csv", 'w+'); $writerAllDomainsDnsHealth = Writer::createFromPath("./subscription-$subscription->uuid-domains/all-domains-dns-health.csv", 'w+'); - $allDomainsSummaryHeader = ['Domain Name', 'Domain UUID', 'Verification Status']; + $allDomainsSummaryHeader = [ + 'Domain Name', + 'Domain UUID', + 'Verification Status', + ]; $writerAllDomains->insertOne($allDomainsSummaryHeader); $verifiedDomainsHeader = ['Domain Name', 'Summary']; @@ -92,11 +98,22 @@ private function writeDomainsToTables(OutputInterface $output, SubscriptionRespo $failedDomainsHeader = $verifiedDomainsHeader; $writerFailedDomains->insertOne($failedDomainsHeader); - $allDomainsDnsHealthCsvHeader = ['Domain Name', 'Domain UUID', 'Domain Health', 'DNS Record Name', 'DNS Record Type', 'DNS Record Value', 'DNS Record Health Details']; + $allDomainsDnsHealthCsvHeader = [ + 'Domain Name', + 'Domain UUID', + 'Domain Health', + 'DNS Record Name', + 'DNS Record Type', + 'DNS Record Value', + 'DNS Record Health Details', + ]; $writerAllDomainsDnsHealth->insertOne($allDomainsDnsHealthCsvHeader); foreach ($domainList as $domain) { - $domainNameAndSummary = [$domain->domain_name, $domain->health->summary]; + $domainNameAndSummary = [ + $domain->domain_name, + $domain->health->summary, + ]; if ($domain->health->code === '200') { $verifiedDomainsTable->addRow($domainNameAndSummary); @@ -146,7 +163,12 @@ private function writeDomainsToTables(OutputInterface $output, SubscriptionRespo } } - $this->renderDomainInfoTables([$allDomainsTable, $verifiedDomainsTable, $pendingDomainsTable, $failedDomainsTable]); + $this->renderDomainInfoTables([ + $allDomainsTable, + $verifiedDomainsTable, + $pendingDomainsTable, + $failedDomainsTable, + ]); } /** @@ -207,17 +229,26 @@ private function renderApplicationAssociations(OutputInterface $output, Client $ $domain->domain_name, var_export($domain->flags->associated, true), ]); - $writerAppsDomains->insertOne([$app->name, $domain->domain_name, var_export($domain->flags->associated, true)]); + $writerAppsDomains->insertOne([ + $app->name, + $domain->domain_name, + var_export($domain->flags->associated, true), + ]); } } else { - $appsDomainsTable->addRow([new TableCell("No domains eligible for association.", [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'yellow', + $appsDomainsTable->addRow([ + new TableCell("No domains eligible for association.", [ + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'yellow', + ]), ]), - ]), ]); - $writerAppsDomains->insertOne([$app->name, 'No domains eligible for association', '']); + $writerAppsDomains->insertOne([ + $app->name, + 'No domains eligible for association', + '', + ]); } } $appsDomainsTable->render(); diff --git a/src/Command/Env/EnvCertCreateCommand.php b/src/Command/Env/EnvCertCreateCommand.php index 2e94b0a51..3b5f763d6 100644 --- a/src/Command/Env/EnvCertCreateCommand.php +++ b/src/Command/Env/EnvCertCreateCommand.php @@ -21,13 +21,13 @@ final class EnvCertCreateCommand extends CommandBase protected function configure(): void { $this - ->addArgument('certificate', InputArgument::REQUIRED, 'Filename of the SSL certificate being installed') - ->addArgument('private-key', InputArgument::REQUIRED, 'Filename of the SSL private key') - ->addOption('legacy', '', InputOption::VALUE_OPTIONAL, 'True for legacy certificates', false) - ->addOption('ca-certificates', '', InputOption::VALUE_OPTIONAL, 'Filename of the CA intermediary certificates') - ->addOption('csr-id', '', InputOption::VALUE_OPTIONAL, 'The CSR (certificate signing request) to associate with this certificate') - ->addOption('label', '', InputOption::VALUE_OPTIONAL, 'The label for this certificate. Required for standard certificates. Optional for legacy certificates', 'My certificate') - ->acceptEnvironmentId(); + ->addArgument('certificate', InputArgument::REQUIRED, 'Filename of the SSL certificate being installed') + ->addArgument('private-key', InputArgument::REQUIRED, 'Filename of the SSL private key') + ->addOption('legacy', '', InputOption::VALUE_OPTIONAL, 'True for legacy certificates', false) + ->addOption('ca-certificates', '', InputOption::VALUE_OPTIONAL, 'Filename of the CA intermediary certificates') + ->addOption('csr-id', '', InputOption::VALUE_OPTIONAL, 'The CSR (certificate signing request) to associate with this certificate') + ->addOption('label', '', InputOption::VALUE_OPTIONAL, 'The label for this certificate. Required for standard certificates. Optional for legacy certificates', 'My certificate') + ->acceptEnvironmentId(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Env/EnvCopyCronCommand.php b/src/Command/Env/EnvCopyCronCommand.php index 4c000d85b..b4a8f690f 100644 --- a/src/Command/Env/EnvCopyCronCommand.php +++ b/src/Command/Env/EnvCopyCronCommand.php @@ -21,11 +21,11 @@ final class EnvCopyCronCommand extends CommandBase protected function configure(): void { $this - ->addArgument('source_env', InputArgument::REQUIRED, 'Alias of the source environment in the format `app-name.env` or the environment uuid') - ->addArgument('dest_env', InputArgument::REQUIRED, 'Alias of the destination environment in the format `app-name.env` or the environment uuid') - ->addUsage(' ') - ->addUsage('myapp.dev myapp.prod') - ->addUsage('abcd1234-1111-2222-3333-0e02b2c3d470 efgh1234-1111-2222-3333-0e02b2c3d470'); + ->addArgument('source_env', InputArgument::REQUIRED, 'Alias of the source environment in the format `app-name.env` or the environment uuid') + ->addArgument('dest_env', InputArgument::REQUIRED, 'Alias of the destination environment in the format `app-name.env` or the environment uuid') + ->addUsage(' ') + ->addUsage('myapp.dev myapp.prod') + ->addUsage('abcd1234-1111-2222-3333-0e02b2c3d470 efgh1234-1111-2222-3333-0e02b2c3d470'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -82,13 +82,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->io->info('Copying the cron task "' . $cron->label . '" from ' . $sourceEnvId . ' to ' . $destEnvId); try { - // Copying the cron on destination environment. - $cronResource->create( - $destEnvId, - $cron->command, - $cronFrequency, - $cron->label, - ); + // Copying the cron on destination environment. + $cronResource->create( + $destEnvId, + $cron->command, + $cronFrequency, + $cron->label, + ); } catch (Exception $e) { $this->io->error('There was some error while copying the cron task "' . $cron->label . '"'); // Log the error for debugging purpose. diff --git a/src/Command/Env/EnvMirrorCommand.php b/src/Command/Env/EnvMirrorCommand.php index 12592a767..18d1f0db6 100644 --- a/src/Command/Env/EnvMirrorCommand.php +++ b/src/Command/Env/EnvMirrorCommand.php @@ -27,13 +27,13 @@ final class EnvMirrorCommand extends CommandBase protected function configure(): void { $this->addArgument('source-environment', InputArgument::REQUIRED, 'The Cloud Platform source environment ID or alias') - ->addUsage('[]') - ->addUsage('myapp.dev') - ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); + ->addUsage('[]') + ->addUsage('myapp.dev') + ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); $this->addArgument('destination-environment', InputArgument::REQUIRED, 'The Cloud Platform destination environment ID or alias') - ->addUsage('[]') - ->addUsage('myapp.dev') - ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); + ->addUsage('[]') + ->addUsage('myapp.dev') + ->addUsage('12345-abcd1234-1111-2222-3333-0e02b2c3d470'); $this->addOption('no-code', 'c'); $this->addOption('no-databases', 'd'); $this->addOption('no-files', 'f'); diff --git a/src/Command/Ide/IdeCreateCommand.php b/src/Command/Ide/IdeCreateCommand.php index f62933d6b..5aa5b3956 100644 --- a/src/Command/Ide/IdeCreateCommand.php +++ b/src/Command/Ide/IdeCreateCommand.php @@ -87,13 +87,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int * Keep this public since it's used as a callback and static analysis tools * think it's unused. * - * @todo use first-class callable syntax instead once we upgrade to PHP 8.1 * @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php + * @todo use first-class callable syntax instead once we upgrade to PHP 8.1 */ public function validateIdeLabel(string $label): string { $violations = Validation::createValidator()->validate($label, [ - new Regex(['pattern' => '/^[\w\' ]+$/', 'message' => 'Use only letters, numbers, and spaces']), + new Regex([ + 'message' => 'Use only letters, numbers, and spaces', + 'pattern' => '/^[\w\' ]+$/', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); diff --git a/src/Command/Ide/IdeOpenCommand.php b/src/Command/Ide/IdeOpenCommand.php index 37f375f30..5b662fa46 100644 --- a/src/Command/Ide/IdeOpenCommand.php +++ b/src/Command/Ide/IdeOpenCommand.php @@ -19,7 +19,7 @@ final class IdeOpenCommand extends IdeCommandBase protected function configure(): void { $this - ->setHidden(AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->setHidden(AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); $this->acceptApplicationUuid(); // @todo Add option to accept an ide UUID. } diff --git a/src/Command/Ide/IdePhpVersionCommand.php b/src/Command/Ide/IdePhpVersionCommand.php index e0194e004..5283b2291 100644 --- a/src/Command/Ide/IdePhpVersionCommand.php +++ b/src/Command/Ide/IdePhpVersionCommand.php @@ -20,8 +20,8 @@ final class IdePhpVersionCommand extends IdeCommandBase protected function configure(): void { $this - ->addArgument('version', InputArgument::REQUIRED, 'The PHP version') - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->addArgument('version', InputArgument::REQUIRED, 'The PHP version') + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -29,7 +29,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->requireCloudIdeEnvironment(); $version = $input->getArgument('version'); $this->validatePhpVersion($version); - $this->localMachineHelper->getFilesystem()->dumpFile($this->getIdePhpVersionFilePath(), $version); + $this->localMachineHelper->getFilesystem() + ->dumpFile($this->getIdePhpVersionFilePath(), $version); $this->restartService('php-fpm'); return Command::SUCCESS; diff --git a/src/Command/Ide/IdeServiceRestartCommand.php b/src/Command/Ide/IdeServiceRestartCommand.php index 58e5dee2d..211bd9d44 100644 --- a/src/Command/Ide/IdeServiceRestartCommand.php +++ b/src/Command/Ide/IdeServiceRestartCommand.php @@ -20,11 +20,11 @@ final class IdeServiceRestartCommand extends IdeCommandBase protected function configure(): void { $this - ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to restart') - ->addUsage('php') - ->addUsage('apache') - ->addUsage('mysql') - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to restart') + ->addUsage('php') + ->addUsage('apache') + ->addUsage('mysql') + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -53,7 +53,14 @@ private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'choices' => [ + 'php', + 'php-fpm', + 'apache', + 'apache2', + 'mysql', + 'mysqld', + ], 'message' => 'Specify a valid service name: php, apache, or mysql', ]), ]); diff --git a/src/Command/Ide/IdeServiceStartCommand.php b/src/Command/Ide/IdeServiceStartCommand.php index 0e1e4bf4e..1034d2c1f 100644 --- a/src/Command/Ide/IdeServiceStartCommand.php +++ b/src/Command/Ide/IdeServiceStartCommand.php @@ -20,11 +20,11 @@ final class IdeServiceStartCommand extends IdeCommandBase protected function configure(): void { $this - ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to start') - ->addUsage('php') - ->addUsage('apache') - ->addUsage('mysql') - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to start') + ->addUsage('php') + ->addUsage('apache') + ->addUsage('mysql') + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -53,7 +53,14 @@ private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'choices' => [ + 'php', + 'php-fpm', + 'apache', + 'apache2', + 'mysql', + 'mysqld', + ], 'message' => 'Specify a valid service name: php, apache, or mysql', ]), ]); diff --git a/src/Command/Ide/IdeServiceStopCommand.php b/src/Command/Ide/IdeServiceStopCommand.php index ae93ff415..954824a9e 100644 --- a/src/Command/Ide/IdeServiceStopCommand.php +++ b/src/Command/Ide/IdeServiceStopCommand.php @@ -20,11 +20,11 @@ final class IdeServiceStopCommand extends IdeCommandBase protected function configure(): void { $this - ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to stop') - ->addUsage('php') - ->addUsage('apache') - ->addUsage('mysql') - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->addArgument('service', InputArgument::REQUIRED, 'The name of the service to stop') + ->addUsage('php') + ->addUsage('apache') + ->addUsage('mysql') + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -53,7 +53,14 @@ private function validateService(string $service): void { $violations = Validation::createValidator()->validate($service, [ new Choice([ - 'choices' => ['php', 'php-fpm', 'apache', 'apache2', 'mysql', 'mysqld'], + 'choices' => [ + 'php', + 'php-fpm', + 'apache', + 'apache2', + 'mysql', + 'mysqld', + ], 'message' => 'Specify a valid service name: php, apache, or mysql', ]), ]); diff --git a/src/Command/Ide/IdeShareCommand.php b/src/Command/Ide/IdeShareCommand.php index 5ebc67658..6d1b4f246 100644 --- a/src/Command/Ide/IdeShareCommand.php +++ b/src/Command/Ide/IdeShareCommand.php @@ -24,8 +24,8 @@ final class IdeShareCommand extends CommandBase protected function configure(): void { $this - ->addOption('regenerate', '', InputOption::VALUE_NONE, 'regenerate the share code') - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->addOption('regenerate', '', InputOption::VALUE_NONE, 'regenerate the share code') + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ide/IdeXdebugToggleCommand.php b/src/Command/Ide/IdeXdebugToggleCommand.php index 14d28f7b8..c7787d247 100644 --- a/src/Command/Ide/IdeXdebugToggleCommand.php +++ b/src/Command/Ide/IdeXdebugToggleCommand.php @@ -19,7 +19,7 @@ final class IdeXdebugToggleCommand extends IdeCommandBase protected function configure(): void { $this - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php b/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php index f6bbb2f0c..1fcac292c 100644 --- a/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php +++ b/src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php @@ -20,7 +20,7 @@ final class IdeWizardCreateSshKeyCommand extends IdeWizardCommandBase protected function configure(): void { $this - ->setHidden(!CommandBase::isAcquiaCloudIde()); + ->setHidden(!CommandBase::isAcquiaCloudIde()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -36,9 +36,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int self::getThisCloudIdeCloudAppUuid(), $account, [ - // Add SSH key to git repository. + // Add SSH key to git repository. "add ssh key to git", - // Add SSH key to non-production environments. + // Add SSH key to non-production environments. "add ssh key to non-prod", ] ); diff --git a/src/Command/Ide/Wizard/IdeWizardDeleteSshKeyCommand.php b/src/Command/Ide/Wizard/IdeWizardDeleteSshKeyCommand.php index 6826f4f69..27814df56 100644 --- a/src/Command/Ide/Wizard/IdeWizardDeleteSshKeyCommand.php +++ b/src/Command/Ide/Wizard/IdeWizardDeleteSshKeyCommand.php @@ -22,7 +22,7 @@ final class IdeWizardDeleteSshKeyCommand extends IdeWizardCommandBase protected function configure(): void { $this - ->setHidden(!CommandBase::isAcquiaCloudIde()); + ->setHidden(!CommandBase::isAcquiaCloudIde()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Pull/PullCodeCommand.php b/src/Command/Pull/PullCodeCommand.php index add6093b1..5a81a5022 100644 --- a/src/Command/Pull/PullCodeCommand.php +++ b/src/Command/Pull/PullCodeCommand.php @@ -21,14 +21,14 @@ final class PullCodeCommand extends PullCommandBase protected function configure(): void { $this - ->acceptEnvironmentId() - ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed') - ->addOption( - 'no-scripts', - null, - InputOption::VALUE_NONE, - 'Do not run any additional scripts after code is pulled. E.g., composer install , drush cache-rebuild, etc.' - ); + ->acceptEnvironmentId() + ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed') + ->addOption( + 'no-scripts', + null, + InputOption::VALUE_NONE, + 'Do not run any additional scripts after code is pulled. E.g., composer install , drush cache-rebuild, etc.' + ); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Pull/PullCommand.php b/src/Command/Pull/PullCommand.php index b01d0440a..2d50403cc 100644 --- a/src/Command/Pull/PullCommand.php +++ b/src/Command/Pull/PullCommand.php @@ -15,24 +15,27 @@ #[RequireAuth] #[RequireDb] -#[AsCommand(name: 'pull:all', description: 'Copy code, database, and files from a Cloud Platform environment', aliases: ['refresh', 'pull'])] +#[AsCommand(name: 'pull:all', description: 'Copy code, database, and files from a Cloud Platform environment', aliases: [ + 'refresh', + 'pull', +])] final class PullCommand extends PullCommandBase { protected function configure(): void { $this - ->acceptEnvironmentId() - ->acceptSite() - ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed') - ->addOption('no-code', null, InputOption::VALUE_NONE, 'Do not refresh code from remote repository') - ->addOption('no-files', null, InputOption::VALUE_NONE, 'Do not refresh files') - ->addOption('no-databases', null, InputOption::VALUE_NONE, 'Do not refresh databases') - ->addOption( - 'no-scripts', - null, - InputOption::VALUE_NONE, - 'Do not run any additional scripts after code and database are copied. E.g., composer install , drush cache-rebuild, etc.' - ); + ->acceptEnvironmentId() + ->acceptSite() + ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed') + ->addOption('no-code', null, InputOption::VALUE_NONE, 'Do not refresh code from remote repository') + ->addOption('no-files', null, InputOption::VALUE_NONE, 'Do not refresh files') + ->addOption('no-databases', null, InputOption::VALUE_NONE, 'Do not refresh databases') + ->addOption( + 'no-scripts', + null, + InputOption::VALUE_NONE, + 'Do not run any additional scripts after code and database are copied. E.g., composer install , drush cache-rebuild, etc.' + ); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Pull/PullCommandBase.php b/src/Command/Pull/PullCommandBase.php index f12954456..75ca778b9 100644 --- a/src/Command/Pull/PullCommandBase.php +++ b/src/Command/Pull/PullCommandBase.php @@ -260,7 +260,12 @@ static function (mixed $totalBytes, mixed $downloadedBytes) use (&$progress, $ou } catch (RequestException $exception) { // Deal with broken SSL certificates. // @see https://timi.eu/docs/anatella/5_1_9_1_list_of_curl_error_codes.html - if (in_array($exception->getHandlerContext()['errno'], [51, 60], true)) { + if ( + in_array($exception->getHandlerContext()['errno'], [ + 51, + 60, + ], true) + ) { $outputCallback('out', 'The certificate for ' . $url->getHost() . ' is invalid.'); assert($url !== null); $domainsResource = new Domains($this->cloudApiClientService->getClient()); @@ -330,7 +335,8 @@ private function createBackup(EnvironmentResponse $environment, DatabaseResponse } /** - * Wait for an on-demand backup to become available (Cloud API notification). + * Wait for an on-demand backup to become available (Cloud API + * notification). * * @infection-ignore-all */ @@ -392,8 +398,10 @@ private function dropDbTables(string $dbHost, string $dbUser, string $dbName, st $tables = $this->listTablesQuoted($process->getOutput()); if ($tables) { $sql = 'DROP TABLE ' . implode(', ', $tables); - $tempnam = $this->localMachineHelper->getFilesystem()->tempnam(sys_get_temp_dir(), 'acli_drop_table_', '.sql'); - $this->localMachineHelper->getFilesystem()->dumpFile($tempnam, $sql); + $tempnam = $this->localMachineHelper->getFilesystem() + ->tempnam(sys_get_temp_dir(), 'acli_drop_table_', '.sql'); + $this->localMachineHelper->getFilesystem() + ->dumpFile($tempnam, $sql); $command = [ 'mysql', '--host', @@ -417,7 +425,10 @@ private function importDatabaseDump(string $localDumpFilepath, string $dbHost, s $outputCallback('out', "Importing downloaded file to database $dbName"); } $this->logger->debug("Importing $localDumpFilepath to MySQL on local machine"); - $this->localMachineHelper->checkRequiredBinariesExist(['gunzip', 'mysql']); + $this->localMachineHelper->checkRequiredBinariesExist([ + 'gunzip', + 'mysql', + ]); if ($this->localMachineHelper->commandExists('pv')) { $command = "pv $localDumpFilepath --bytes --rate | gunzip | MYSQL_PWD=$dbPassword mysql --host=$dbHost --user=$dbUser $dbName"; } else { @@ -457,7 +468,10 @@ private function rsyncFilesFromCloud(EnvironmentResponse $chosenEnvironment, Clo protected function determineCloneProject(OutputInterface $output): bool { - $finder = $this->localMachineHelper->getFinder()->files()->in($this->dir)->ignoreDotFiles(false); + $finder = $this->localMachineHelper->getFinder() + ->files() + ->in($this->dir) + ->ignoreDotFiles(false); // If we are in an IDE, assume we should pull into /home/ide/project. if ($this->dir === '/home/ide/project' && AcquiaDrupalEnvironmentDetector::isAhIdeEnv() && !$finder->hasResults()) { @@ -521,7 +535,10 @@ protected function matchIdePhpVersion( if ($answer) { $command = $this->getApplication()->find('ide:php-version'); $command->run( - new ArrayInput(['command' => 'ide:php-version', 'version' => $chosenEnvironment->configuration->php->version]), + new ArrayInput([ + 'command' => 'ide:php-version', + 'version' => $chosenEnvironment->configuration->php->version, + ]), $output ); } diff --git a/src/Command/Pull/PullDatabaseCommand.php b/src/Command/Pull/PullDatabaseCommand.php index 19514c15e..aa4acd7f9 100644 --- a/src/Command/Pull/PullDatabaseCommand.php +++ b/src/Command/Pull/PullDatabaseCommand.php @@ -20,33 +20,33 @@ final class PullDatabaseCommand extends PullCommandBase protected function configure(): void { $this - ->setHelp('This uses the latest available database backup, which may be up to 24 hours old. If no backup exists, one will be created.') - ->acceptEnvironmentId() - ->acceptSite() - ->addOption( - 'no-scripts', - null, - InputOption::VALUE_NONE, - 'Do not run any additional scripts after the database is pulled. E.g., drush cache-rebuild, drush sql-sanitize, etc.' - ) - ->addOption( - 'on-demand', - null, - InputOption::VALUE_NONE, - 'Force creation of an on-demand backup. This takes much longer than using an existing backup (when one is available)' - ) - ->addOption( - 'no-import', - null, - InputOption::VALUE_NONE, - 'Download the backup but do not import it (implies --no-scripts)' - ) - ->addOption( - 'multiple-dbs', - null, - InputOption::VALUE_NONE, - 'Download multiple dbs. Defaults to FALSE.' - ); + ->setHelp('This uses the latest available database backup, which may be up to 24 hours old. If no backup exists, one will be created.') + ->acceptEnvironmentId() + ->acceptSite() + ->addOption( + 'no-scripts', + null, + InputOption::VALUE_NONE, + 'Do not run any additional scripts after the database is pulled. E.g., drush cache-rebuild, drush sql-sanitize, etc.' + ) + ->addOption( + 'on-demand', + null, + InputOption::VALUE_NONE, + 'Force creation of an on-demand backup. This takes much longer than using an existing backup (when one is available)' + ) + ->addOption( + 'no-import', + null, + InputOption::VALUE_NONE, + 'Download the backup but do not import it (implies --no-scripts)' + ) + ->addOption( + 'multiple-dbs', + null, + InputOption::VALUE_NONE, + 'Download multiple dbs. Defaults to FALSE.' + ); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Pull/PullFilesCommand.php b/src/Command/Pull/PullFilesCommand.php index a42eea055..44eac3f79 100644 --- a/src/Command/Pull/PullFilesCommand.php +++ b/src/Command/Pull/PullFilesCommand.php @@ -17,8 +17,8 @@ final class PullFilesCommand extends PullCommandBase protected function configure(): void { $this - ->acceptEnvironmentId() - ->acceptSite(); + ->acceptEnvironmentId() + ->acceptSite(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Pull/PullScriptsCommand.php b/src/Command/Pull/PullScriptsCommand.php index 4ab34d089..16d0ba908 100644 --- a/src/Command/Pull/PullScriptsCommand.php +++ b/src/Command/Pull/PullScriptsCommand.php @@ -20,8 +20,8 @@ final class PullScriptsCommand extends CommandBase protected function configure(): void { $this - ->acceptEnvironmentId() - ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed'); + ->acceptEnvironmentId() + ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be refreshed'); } protected function initialize(InputInterface $input, OutputInterface $output): void diff --git a/src/Command/Push/PushArtifactCommand.php b/src/Command/Push/PushArtifactCommand.php index 9477ef84b..0c7d65e8b 100644 --- a/src/Command/Push/PushArtifactCommand.php +++ b/src/Command/Push/PushArtifactCommand.php @@ -44,23 +44,23 @@ final class PushArtifactCommand extends CommandBase protected function configure(): void { $this - ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be pushed') - ->addOption('no-sanitize', null, InputOption::VALUE_NONE, 'Do not sanitize the build artifact') - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Deprecated: Use no-push instead') - ->addOption('no-push', null, InputOption::VALUE_NONE, 'Do not push changes to Acquia Cloud') - ->addOption('no-commit', null, InputOption::VALUE_NONE, 'Do not commit changes. Implies no-push') - ->addOption('no-clone', null, InputOption::VALUE_NONE, 'Do not clone repository. Implies no-commit and no-push') - ->addOption('destination-git-urls', 'u', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'The URL(s) of your git repository to which the artifact branch will be pushed') - ->addOption('destination-git-branch', 'b', InputOption::VALUE_REQUIRED, 'The destination branch to push the artifact to') - ->addOption('destination-git-tag', 't', InputOption::VALUE_REQUIRED, 'The destination tag to push the artifact to. Using this option requires also using the --source-git-tag option') - ->addOption('source-git-tag', 's', InputOption::VALUE_REQUIRED, 'The source tag from which to create the tag artifact') - ->acceptEnvironmentId() - ->setHelp('This command builds a sanitized deploy artifact by running composer install, removing sensitive files, and committing vendor directories.' . PHP_EOL . PHP_EOL - . 'Vendor directories and scaffold files are committed to the build artifact even if they are ignored in the source repository.' . PHP_EOL . PHP_EOL - . 'To run additional build or sanitization steps (e.g. npm install), add a post-install-cmd script to your composer.json file: https://getcomposer.org/doc/articles/scripts.md#command-events') - ->addUsage('--destination-git-branch=main-build') - ->addUsage('--source-git-tag=foo-build --destination-git-tag=1.0.0') - ->addUsage('--destination-git-urls=example@svn-1.prod.hosting.acquia.com:example.git --destination-git-branch=main-build'); + ->addOption('dir', null, InputArgument::OPTIONAL, 'The directory containing the Drupal project to be pushed') + ->addOption('no-sanitize', null, InputOption::VALUE_NONE, 'Do not sanitize the build artifact') + ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Deprecated: Use no-push instead') + ->addOption('no-push', null, InputOption::VALUE_NONE, 'Do not push changes to Acquia Cloud') + ->addOption('no-commit', null, InputOption::VALUE_NONE, 'Do not commit changes. Implies no-push') + ->addOption('no-clone', null, InputOption::VALUE_NONE, 'Do not clone repository. Implies no-commit and no-push') + ->addOption('destination-git-urls', 'u', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'The URL(s) of your git repository to which the artifact branch will be pushed') + ->addOption('destination-git-branch', 'b', InputOption::VALUE_REQUIRED, 'The destination branch to push the artifact to') + ->addOption('destination-git-tag', 't', InputOption::VALUE_REQUIRED, 'The destination tag to push the artifact to. Using this option requires also using the --source-git-tag option') + ->addOption('source-git-tag', 's', InputOption::VALUE_REQUIRED, 'The source tag from which to create the tag artifact') + ->acceptEnvironmentId() + ->setHelp('This command builds a sanitized deploy artifact by running composer install, removing sensitive files, and committing vendor directories.' . PHP_EOL . PHP_EOL + . 'Vendor directories and scaffold files are committed to the build artifact even if they are ignored in the source repository.' . PHP_EOL . PHP_EOL + . 'To run additional build or sanitization steps (e.g. npm install), add a post-install-cmd script to your composer.json file: https://getcomposer.org/doc/articles/scripts.md#command-events') + ->addUsage('--destination-git-branch=main-build') + ->addUsage('--source-git-tag=foo-build --destination-git-tag=1.0.0') + ->addUsage('--destination-git-urls=example@svn-1.prod.hosting.acquia.com:example.git --destination-git-branch=main-build'); } protected function initialize(InputInterface $input, OutputInterface $output): void @@ -218,8 +218,20 @@ private function cloneSourceBranch(Closure $outputCallback, string $artifactDir, } $outputCallback('out', 'Global .gitignore file is temporarily disabled during artifact builds.'); - $this->localMachineHelper->execute(['git', 'config', '--local', 'core.excludesFile', 'false'], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); - $this->localMachineHelper->execute(['git', 'config', '--local', 'core.fileMode', 'true'], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $this->localMachineHelper->execute([ + 'git', + 'config', + '--local', + 'core.excludesFile', + 'false', + ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $this->localMachineHelper->execute([ + 'git', + 'config', + '--local', + 'core.fileMode', + 'true', + ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); // Vendor directories can be "corrupt" (i.e. missing scaffold files due to earlier sanitization) in ways that break composer install. $outputCallback('out', 'Removing vendor directories'); @@ -238,18 +250,25 @@ private function buildArtifact(Closure $outputCallback, string $artifactDir): vo $outputCallback('out', "Mirroring source files from $this->dir to $artifactDir"); $originFinder = $this->localMachineHelper->getFinder(); $originFinder->in($this->dir) - // Include dot files like .htaccess. - ->ignoreDotFiles(false) - // Ignore VCS ignored files (e.g. vendor) to speed up the mirror (Composer will restore them later). - ->ignoreVCSIgnored(true); + // Include dot files like .htaccess. + ->ignoreDotFiles(false) + // Ignore VCS ignored files (e.g. vendor) to speed up the mirror (Composer will restore them later). + ->ignoreVCSIgnored(true); $targetFinder = $this->localMachineHelper->getFinder(); $targetFinder->in($artifactDir)->ignoreDotFiles(false); $this->localMachineHelper->getFilesystem()->remove($targetFinder); - $this->localMachineHelper->getFilesystem()->mirror($this->dir, $artifactDir, $originFinder, ['override' => true]); + $this->localMachineHelper->getFilesystem() + ->mirror($this->dir, $artifactDir, $originFinder, ['override' => true]); $this->localMachineHelper->checkRequiredBinariesExist(['composer']); $outputCallback('out', 'Installing Composer production dependencies'); - $process = $this->localMachineHelper->execute(['composer', 'install', '--no-dev', '--no-interaction', '--optimize-autoloader'], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $process = $this->localMachineHelper->execute([ + 'composer', + 'install', + '--no-dev', + '--no-interaction', + '--optimize-autoloader', + ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException("Unable to install composer dependencies: {message}", ['message' => $process->getOutput() . $process->getErrorOutput()]); } @@ -262,20 +281,21 @@ private function sanitizeArtifact(Closure $outputCallback, string $artifactDir): { $outputCallback('out', 'Finding Drupal core text files'); $sanitizeFinder = $this->localMachineHelper->getFinder() - ->files() - ->name('*.txt') - ->notName('LICENSE.txt') - ->in("$artifactDir/docroot/core"); + ->files() + ->name('*.txt') + ->notName('LICENSE.txt') + ->in("$artifactDir/docroot/core"); $outputCallback('out', 'Finding VCS directories'); $vcsFinder = $this->localMachineHelper->getFinder() - ->ignoreDotFiles(false) - ->ignoreVCS(false) - ->directories() - ->in(["$artifactDir/docroot", - "$artifactDir/vendor", - ]) - ->name('.git'); + ->ignoreDotFiles(false) + ->ignoreVCS(false) + ->directories() + ->in([ + "$artifactDir/docroot", + "$artifactDir/vendor", + ]) + ->name('.git'); $drushDir = "$artifactDir/drush"; if (file_exists($drushDir)) { $vcsFinder->in($drushDir); @@ -286,9 +306,9 @@ private function sanitizeArtifact(Closure $outputCallback, string $artifactDir): $outputCallback('out', 'Finding INSTALL database text files'); $dbInstallFinder = $this->localMachineHelper->getFinder() - ->files() - ->in([$artifactDir]) - ->name('/INSTALL\.[a-z]+\.(md|txt)$/'); + ->files() + ->in([$artifactDir]) + ->name('/INSTALL\.[a-z]+\.(md|txt)$/'); if ($dbInstallFinder->hasResults()) { $sanitizeFinder->append($dbInstallFinder); } @@ -306,9 +326,9 @@ private function sanitizeArtifact(Closure $outputCallback, string $artifactDir): 'UPDATE', ]; $textFileFinder = $this->localMachineHelper->getFinder() - ->files() - ->in(["$artifactDir/docroot"]) - ->name('/(' . implode('|', $filenames) . ')\.(md|txt)$/'); + ->files() + ->in(["$artifactDir/docroot"]) + ->name('/(' . implode('|', $filenames) . ')\.(md|txt)$/'); if ($textFileFinder->hasResults()) { $sanitizeFinder->append($textFileFinder); } @@ -324,20 +344,34 @@ private function commit(Closure $outputCallback, string $artifactDir, string $co { $outputCallback('out', 'Adding and committing changed files'); $this->localMachineHelper->checkRequiredBinariesExist(['git']); - $process = $this->localMachineHelper->execute(['git', 'add', '-A'], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $process = $this->localMachineHelper->execute([ + 'git', + 'add', + '-A', + ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException("Could not add files to artifact via git: {message}", ['message' => $process->getErrorOutput() . $process->getOutput()]); } foreach (array_merge($this->vendorDirs(), $this->scaffoldFiles($artifactDir)) as $file) { $this->logger->debug("Forcibly adding $file"); - $this->localMachineHelper->execute(['git', 'add', '-f', $file], null, $artifactDir, false); + $this->localMachineHelper->execute([ + 'git', + 'add', + '-f', + $file, + ], null, $artifactDir, false); if (!$process->isSuccessful()) { // This will fatally error if the file doesn't exist. Suppress error output. $this->io->warning("Unable to forcibly add $file to new branch"); } } $commitMessage = $this->generateCommitMessage($commitHash); - $process = $this->localMachineHelper->execute(['git', 'commit', '-m', $commitMessage], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); + $process = $this->localMachineHelper->execute([ + 'git', + 'commit', + '-m', + $commitMessage, + ], $outputCallback, $artifactDir, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); if (!$process->isSuccessful()) { throw new AcquiaCliException("Could not commit via git: {message}", ['message' => $process->getErrorOutput() . $process->getOutput()]); } diff --git a/src/Command/Push/PushCodeCommand.php b/src/Command/Push/PushCodeCommand.php index f05b0577e..81eaf08eb 100644 --- a/src/Command/Push/PushCodeCommand.php +++ b/src/Command/Push/PushCodeCommand.php @@ -18,7 +18,7 @@ final class PushCodeCommand extends PushCommandBase protected function configure(): void { $this - ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv() && !self::isLandoEnv()); + ->setHidden(!AcquiaDrupalEnvironmentDetector::isAhIdeEnv() && !self::isLandoEnv()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Push/PushDatabaseCommand.php b/src/Command/Push/PushDatabaseCommand.php index 0bfd6609d..b893f11e7 100644 --- a/src/Command/Push/PushDatabaseCommand.php +++ b/src/Command/Push/PushDatabaseCommand.php @@ -23,8 +23,8 @@ final class PushDatabaseCommand extends PushCommandBase protected function configure(): void { $this - ->acceptEnvironmentId() - ->acceptSite(); + ->acceptEnvironmentId() + ->acceptSite(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Push/PushFilesCommand.php b/src/Command/Push/PushFilesCommand.php index 1414bbaf6..376002571 100644 --- a/src/Command/Push/PushFilesCommand.php +++ b/src/Command/Push/PushFilesCommand.php @@ -19,8 +19,8 @@ final class PushFilesCommand extends PushCommandBase protected function configure(): void { $this - ->acceptEnvironmentId() - ->acceptSite(); + ->acceptEnvironmentId() + ->acceptSite(); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Remote/AliasListCommand.php b/src/Command/Remote/AliasListCommand.php index bb769778b..2512c8714 100644 --- a/src/Command/Remote/AliasListCommand.php +++ b/src/Command/Remote/AliasListCommand.php @@ -15,7 +15,10 @@ use Symfony\Component\Console\Output\OutputInterface; #[RequireAuth] -#[AsCommand(name: 'remote:aliases:list', description: 'List all aliases for the Cloud Platform environments', aliases: ['aliases', 'sa'])] +#[AsCommand(name: 'remote:aliases:list', description: 'List all aliases for the Cloud Platform environments', aliases: [ + 'aliases', + 'sa', +])] final class AliasListCommand extends CommandBase { protected function configure(): void @@ -32,7 +35,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $environmentsResource = new Environments($acquiaCloudClient); $table = new Table($this->output); - $table->setHeaders(['Application', 'Environment Alias', 'Environment UUID']); + $table->setHeaders([ + 'Application', + 'Environment Alias', + 'Environment UUID', + ]); $siteId = $customerApplication->hosting->id; $parts = explode(':', $siteId); @@ -40,7 +47,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $environments = $environmentsResource->getAll($customerApplication->uuid); foreach ($environments as $environment) { $alias = $sitePrefix . '.' . $environment->name; - $table->addRow([$customerApplication->name, $alias, $environment->uuid]); + $table->addRow([ + $customerApplication->name, + $alias, + $environment->uuid, + ]); } $table->render(); diff --git a/src/Command/Remote/AliasesDownloadCommand.php b/src/Command/Remote/AliasesDownloadCommand.php index da296796c..771542ba9 100644 --- a/src/Command/Remote/AliasesDownloadCommand.php +++ b/src/Command/Remote/AliasesDownloadCommand.php @@ -30,8 +30,8 @@ final class AliasesDownloadCommand extends SshBaseCommand protected function configure(): void { $this - ->addOption('destination-dir', null, InputOption::VALUE_REQUIRED, 'The directory to which aliases will be downloaded') - ->addOption('all', null, InputOption::VALUE_NONE, 'Download the aliases for all applications that you have access to, not just the current one.'); + ->addOption('destination-dir', null, InputOption::VALUE_REQUIRED, 'The directory to which aliases will be downloaded') + ->addOption('all', null, InputOption::VALUE_NONE, 'Download the aliases for all applications that you have access to, not just the current one.'); $this->acceptApplicationUuid(); } @@ -41,7 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $drushArchiveTempFilepath = $this->getDrushArchiveTempFilepath(); $drushAliasesDir = $this->getDrushAliasesDir($aliasVersion); $this->localMachineHelper->getFilesystem()->mkdir($drushAliasesDir); - $this->localMachineHelper->getFilesystem()->chmod($drushAliasesDir, 0700); + $this->localMachineHelper->getFilesystem() + ->chmod($drushAliasesDir, 0700); if ($aliasVersion === '9') { $this->downloadDrush9Aliases($input, $aliasVersion, $drushArchiveTempFilepath, $drushAliasesDir); diff --git a/src/Command/Remote/DrushCommand.php b/src/Command/Remote/DrushCommand.php index 0b8c0bad8..be04d1400 100644 --- a/src/Command/Remote/DrushCommand.php +++ b/src/Command/Remote/DrushCommand.php @@ -14,18 +14,21 @@ * A command to proxy Drush commands on an environment using SSH. */ #[RequireAuth] -#[AsCommand(name: 'remote:drush', description: 'Run a Drush command remotely on a Cloud Platform environment', aliases: ['drush', 'dr'])] +#[AsCommand(name: 'remote:drush', description: 'Run a Drush command remotely on a Cloud Platform environment', aliases: [ + 'drush', + 'dr', +])] final class DrushCommand extends SshBaseCommand { protected function configure(): void { $this - ->setHelp('Pay close attention to the argument syntax! Note the usage of -- to separate the drush command arguments and options.') - ->acceptEnvironmentId() - ->addArgument('drush_command', InputArgument::IS_ARRAY, 'Drush command') - ->addUsage('. -- ') - ->addUsage('myapp.dev -- uli 1') - ->addUsage('myapp.dev -- status --fields=db-status'); + ->setHelp('Pay close attention to the argument syntax! Note the usage of -- to separate the drush command arguments and options.') + ->acceptEnvironmentId() + ->addArgument('drush_command', InputArgument::IS_ARRAY, 'Drush command') + ->addUsage('. -- ') + ->addUsage('myapp.dev -- uli 1') + ->addUsage('myapp.dev -- status --fields=db-status'); } protected function execute(InputInterface $input, OutputInterface $output): ?int @@ -45,6 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int implode(' ', $drushArguments), ]; - return $this->sshHelper->executeCommand($environment->sshUrl, $drushCommandArguments)->getExitCode(); + return $this->sshHelper->executeCommand($environment->sshUrl, $drushCommandArguments) + ->getExitCode(); } } diff --git a/src/Command/Remote/SshCommand.php b/src/Command/Remote/SshCommand.php index cd5841d36..6dc73a6cd 100644 --- a/src/Command/Remote/SshCommand.php +++ b/src/Command/Remote/SshCommand.php @@ -21,10 +21,10 @@ final class SshCommand extends SshBaseCommand protected function configure(): void { $this - ->addArgument('alias', InputArgument::REQUIRED, 'Alias for application & environment in the format `app-name.env`') - ->addArgument('ssh_command', InputArgument::IS_ARRAY, 'Command to run via SSH (if not provided, opens a shell in the site directory)') - ->addUsage("myapp.dev # open a shell in the myapp.dev environment") - ->addUsage("myapp.dev -- ls -al # list files in the myapp.dev environment and return"); + ->addArgument('alias', InputArgument::REQUIRED, 'Alias for application & environment in the format `app-name.env`') + ->addArgument('ssh_command', InputArgument::IS_ARRAY, 'Command to run via SSH (if not provided, opens a shell in the site directory)') + ->addUsage("myapp.dev # open a shell in the myapp.dev environment") + ->addUsage("myapp.dev -- ls -al # list files in the myapp.dev environment and return"); } protected function execute(InputInterface $input, OutputInterface $output): ?int @@ -46,6 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int $sshCommand[] = implode(' ', $arguments['ssh_command']); } $sshCommand = (array) implode('; ', $sshCommand); - return $this->sshHelper->executeCommand($environment->sshUrl, $sshCommand)->getExitCode(); + return $this->sshHelper->executeCommand($environment->sshUrl, $sshCommand) + ->getExitCode(); } } diff --git a/src/Command/Self/ClearCacheCommand.php b/src/Command/Self/ClearCacheCommand.php index f68408ef2..b984aab03 100644 --- a/src/Command/Self/ClearCacheCommand.php +++ b/src/Command/Self/ClearCacheCommand.php @@ -12,7 +12,10 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Path; -#[AsCommand(name: 'self:clear-caches', description: 'Clears local Acquia CLI caches', aliases: ['cc', 'cr'])] +#[AsCommand(name: 'self:clear-caches', description: 'Clears local Acquia CLI caches', aliases: [ + 'cc', + 'cr', +])] final class ClearCacheCommand extends CommandBase { protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Self/ListCommand.php b/src/Command/Self/ListCommand.php index b8a8c940b..7bd9d7d6a 100644 --- a/src/Command/Self/ListCommand.php +++ b/src/Command/Self/ListCommand.php @@ -22,15 +22,15 @@ final class ListCommand extends CommandBase protected function configure(): void { $this - ->setName('list') - ->setDefinition([ - new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())), - new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), - new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()), - new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), - ]) - ->setDescription('List commands') - ->setHelp(<<<'EOF' + ->setName('list') + ->setDefinition([ + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn() => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn() => (new DescriptorHelper())->getFormats()), + new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), + ]) + ->setDescription('List commands') + ->setHelp(<<<'EOF' The %command.name% command lists all commands: %command.full_name% @@ -47,7 +47,7 @@ protected function configure(): void %command.full_name% --raw EOF - ); + ); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ssh/SshKeyCommandBase.php b/src/Command/Ssh/SshKeyCommandBase.php index 55a3a71b3..2ea779166 100644 --- a/src/Command/Ssh/SshKeyCommandBase.php +++ b/src/Command/Ssh/SshKeyCommandBase.php @@ -55,7 +55,8 @@ private static function normalizeSshKeyLabel(?string $label): string|null } /** - * Normalizes public SSH key by trimming and removing user and machine suffix. + * Normalizes public SSH key by trimming and removing user and machine + * suffix. */ protected function normalizePublicSshKey(string $publicKey): string { @@ -91,7 +92,8 @@ protected function addSshKeyToAgent(string $filepath, string $password): void { // We must use a separate script to mimic user input due to the limitations of the `ssh-add` command. // @see https://www.linux.com/topic/networking/manage-ssh-key-file-passphrase/ - $tempFilepath = $this->localMachineHelper->getFilesystem()->tempnam(sys_get_temp_dir(), 'acli'); + $tempFilepath = $this->localMachineHelper->getFilesystem() + ->tempnam(sys_get_temp_dir(), 'acli'); $this->localMachineHelper->writeFile($tempFilepath, <<<'EOT' #!/usr/bin/env bash echo $SSH_PASS @@ -107,8 +109,8 @@ protected function addSshKeyToAgent(string $filepath, string $password): void } /** - * Polls the Cloud Platform until a successful SSH request is made to the dev - * environment. + * Polls the Cloud Platform until a successful SSH request is made to the + * dev environment. * * @infection-ignore-all */ @@ -119,7 +121,8 @@ protected function pollAcquiaCloudUntilSshSuccess( $timers = []; $startTime = time(); $cloudAppUuid = $this->determineCloudApplication(true); - $permissions = $this->cloudApiClientService->getClient()->request('get', "/applications/$cloudAppUuid/permissions"); + $permissions = $this->cloudApiClientService->getClient() + ->request('get', "/applications/$cloudAppUuid/permissions"); $perms = array_column($permissions, 'name'); $mappings = $this->checkPermissions($perms, $cloudAppUuid, $output); foreach ($mappings as $envName => $config) { @@ -153,7 +156,11 @@ static function () use ($spinner): void { } if (empty($mappings)) { // SSH key is available on every host. - Amplitude::getInstance()->queueEvent('SSH key upload', ['result' => 'success', 'duration' => time() - $startTime]); + Amplitude::getInstance() + ->queueEvent('SSH key upload', [ + 'duration' => time() - $startTime, + 'result' => 'success', + ]); $output->writeln("\nYour SSH key is ready for use!\n"); foreach ($timers as $timer) { Loop::cancelTimer($timer); @@ -167,7 +174,8 @@ static function () use ($spinner): void { $timers[] = Loop::addTimer(60 * 60, static function () use ($output, &$timers): void { // Upload timed out. $output->writeln("\nThis is taking longer than usual. It will happen eventually!\n"); - Amplitude::getInstance()->queueEvent('SSH key upload', ['result' => 'timeout']); + Amplitude::getInstance() + ->queueEvent('SSH key upload', ['result' => 'timeout']); foreach ($timers as $timer) { Loop::cancelTimer($timer); } @@ -182,7 +190,11 @@ static function () use ($spinner): void { private function checkPermissions(array $userPerms, string $cloudAppUuid, OutputInterface $output): array { $mappings = []; - $requiredPerms = ['add ssh key to git', 'add ssh key to non-prod', 'add ssh key to prod']; + $requiredPerms = [ + 'add ssh key to git', + 'add ssh key to non-prod', + 'add ssh key to prod', + ]; foreach ($requiredPerms as $index => $requiredPerm) { if (in_array($requiredPerm, $userPerms, true)) { switch ($requiredPerm) { @@ -193,7 +205,7 @@ private function checkPermissions(array $userPerms, string $cloudAppUuid, Output break; case 'add ssh key to non-prod': if ($nonProdEnv = $this->getAnyNonProdAhEnvironment($cloudAppUuid)) { - $mappings['nonprod']['ssh_target'] = $nonProdEnv->sshUrl; + $mappings['nonprod']['ssh_target'] = $nonProdEnv->sshUrl; } break; case 'add ssh key to prod': @@ -267,7 +279,10 @@ private function validateFilename(string $filename): string $violations = Validation::createValidator()->validate($filename, [ new Length(['min' => 5]), new NotBlank(), - new Regex(['pattern' => '/^\S*$/', 'message' => 'The value may not contain spaces']), + new Regex([ + 'message' => 'The value may not contain spaces', + 'pattern' => '/^\S*$/', + ]), ]); if (count($violations)) { throw new ValidatorException($violations->get(0)->getMessage()); @@ -324,7 +339,10 @@ protected function determinePublicSshKey(string $filepath = null): array } if ($filepath) { - if (!$this->localMachineHelper->getFilesystem()->exists($filepath)) { + if ( + !$this->localMachineHelper->getFilesystem() + ->exists($filepath) + ) { throw new AcquiaCliException('The filepath {filepath} is not valid', ['filepath' => $filepath]); } if (!str_contains($filepath, '.pub')) { diff --git a/src/Command/Ssh/SshKeyCreateCommand.php b/src/Command/Ssh/SshKeyCreateCommand.php index 0c88737a4..caf51432d 100644 --- a/src/Command/Ssh/SshKeyCreateCommand.php +++ b/src/Command/Ssh/SshKeyCreateCommand.php @@ -18,8 +18,8 @@ final class SshKeyCreateCommand extends SshKeyCommandBase protected function configure(): void { $this - ->addOption('filename', null, InputOption::VALUE_REQUIRED, 'The filename of the SSH key') - ->addOption('password', null, InputOption::VALUE_REQUIRED, 'The password for the SSH key'); + ->addOption('filename', null, InputOption::VALUE_REQUIRED, 'The filename of the SSH key') + ->addOption('password', null, InputOption::VALUE_REQUIRED, 'The password for the SSH key'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ssh/SshKeyCreateUploadCommand.php b/src/Command/Ssh/SshKeyCreateUploadCommand.php index 521f6f362..4f5815a49 100644 --- a/src/Command/Ssh/SshKeyCreateUploadCommand.php +++ b/src/Command/Ssh/SshKeyCreateUploadCommand.php @@ -18,10 +18,10 @@ final class SshKeyCreateUploadCommand extends SshKeyCommandBase protected function configure(): void { $this - ->addOption('filename', null, InputOption::VALUE_REQUIRED, 'The filename of the SSH key') - ->addOption('password', null, InputOption::VALUE_REQUIRED, 'The password for the SSH key') - ->addOption('label', null, InputOption::VALUE_REQUIRED, 'The SSH key label to be used with the Cloud Platform') - ->addOption('no-wait', null, InputOption::VALUE_NONE, "Don't wait for the SSH key to be uploaded to the Cloud Platform"); + ->addOption('filename', null, InputOption::VALUE_REQUIRED, 'The filename of the SSH key') + ->addOption('password', null, InputOption::VALUE_REQUIRED, 'The password for the SSH key') + ->addOption('label', null, InputOption::VALUE_REQUIRED, 'The SSH key label to be used with the Cloud Platform') + ->addOption('no-wait', null, InputOption::VALUE_NONE, "Don't wait for the SSH key to be uploaded to the Cloud Platform"); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ssh/SshKeyDeleteCommand.php b/src/Command/Ssh/SshKeyDeleteCommand.php index 47012ef3b..594668a77 100644 --- a/src/Command/Ssh/SshKeyDeleteCommand.php +++ b/src/Command/Ssh/SshKeyDeleteCommand.php @@ -20,7 +20,7 @@ final class SshKeyDeleteCommand extends SshKeyCommandBase protected function configure(): void { $this - ->addOption('cloud-key-uuid', 'uuid', InputOption::VALUE_REQUIRED); + ->addOption('cloud-key-uuid', 'uuid', InputOption::VALUE_REQUIRED); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ssh/SshKeyInfoCommand.php b/src/Command/Ssh/SshKeyInfoCommand.php index 67bd204cf..c33f49352 100644 --- a/src/Command/Ssh/SshKeyInfoCommand.php +++ b/src/Command/Ssh/SshKeyInfoCommand.php @@ -21,8 +21,8 @@ final class SshKeyInfoCommand extends SshKeyCommandBase protected function configure(): void { $this - ->addOption('fingerprint', null, InputOption::VALUE_REQUIRED, 'sha256 fingerprint') - ->addUsage('--fingerprint=pyarUa1mt2ln4fmrp7alWKpv1IPneqFwE+ErTC71IvY='); + ->addOption('fingerprint', null, InputOption::VALUE_REQUIRED, 'sha256 fingerprint') + ->addUsage('--fingerprint=pyarUa1mt2ln4fmrp7alWKpv1IPneqFwE+ErTC71IvY='); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Command/Ssh/SshKeyListCommand.php b/src/Command/Ssh/SshKeyListCommand.php index c70cf1001..db7c5e3c6 100644 --- a/src/Command/Ssh/SshKeyListCommand.php +++ b/src/Command/Ssh/SshKeyListCommand.php @@ -69,7 +69,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function createSshKeyTable(OutputInterface $output, string $title): Table { - $headers = ['Cloud Platform label', 'Local filename', 'Fingerprint (sha256)']; + $headers = [ + 'Cloud Platform label', + 'Local filename', + 'Fingerprint (sha256)', + ]; $widths = [.4, .2, .2]; return $this->createTable($output, $title, $headers, $widths); } diff --git a/src/Command/Ssh/SshKeyUploadCommand.php b/src/Command/Ssh/SshKeyUploadCommand.php index 191c5e9e2..be01d2e17 100644 --- a/src/Command/Ssh/SshKeyUploadCommand.php +++ b/src/Command/Ssh/SshKeyUploadCommand.php @@ -18,9 +18,9 @@ final class SshKeyUploadCommand extends SshKeyCommandBase protected function configure(): void { $this - ->addOption('filepath', null, InputOption::VALUE_REQUIRED, 'The filepath of the public SSH key to upload') - ->addOption('label', null, InputOption::VALUE_REQUIRED, 'The SSH key label to be used with the Cloud Platform') - ->addOption('no-wait', null, InputOption::VALUE_NONE, "Don't wait for the SSH key to be uploaded to the Cloud Platform"); + ->addOption('filepath', null, InputOption::VALUE_REQUIRED, 'The filepath of the public SSH key to upload') + ->addOption('label', null, InputOption::VALUE_REQUIRED, 'The SSH key label to be used with the Cloud Platform') + ->addOption('no-wait', null, InputOption::VALUE_NONE, "Don't wait for the SSH key to be uploaded to the Cloud Platform"); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Config/AcquiaCliConfig.php b/src/Config/AcquiaCliConfig.php index 14fc4b59d..7d0f6c3c2 100644 --- a/src/Config/AcquiaCliConfig.php +++ b/src/Config/AcquiaCliConfig.php @@ -18,11 +18,11 @@ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('acquia_cli'); $treeBuilder - ->getRootNode() - ->children() - ->scalarNode('cloud_app_uuid') - ->end() - ->end(); + ->getRootNode() + ->children() + ->scalarNode('cloud_app_uuid') + ->end() + ->end(); return $treeBuilder; } } diff --git a/src/Config/CloudDataConfig.php b/src/Config/CloudDataConfig.php index 61d89e3f4..4f0c5bdba 100644 --- a/src/Config/CloudDataConfig.php +++ b/src/Config/CloudDataConfig.php @@ -19,63 +19,57 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder = new TreeBuilder('cloud_api'); $rootNode = $treeBuilder->getRootNode(); $rootNode - ->children() - - // I can't find a better node type that accepts TRUE, FALSE, and NULL. - // boolNode() will cast NULL to FALSE and enumNode()->values() will - // strip out a NULL value. - ->scalarNode('send_telemetry')->end() - - ->scalarNode('acli_key')->end() + ->children() - ->arrayNode('keys') + // I can't find a better node type that accepts TRUE, FALSE, and NULL. + // boolNode() will cast NULL to FALSE and enumNode()->values() will + // strip out a NULL value. + ->scalarNode('send_telemetry')->end() + ->scalarNode('acli_key')->end() + ->arrayNode('keys') ->useAttributeAsKey('uuid') ->normalizeKeys(false) ->arrayPrototype() - ->children() - ->scalarNode('label')->end() - ->scalarNode('uuid')->end() - ->scalarNode('secret')->isRequired()->end() - ->end() + ->children() + ->scalarNode('label')->end() + ->scalarNode('uuid')->end() + ->scalarNode('secret')->isRequired()->end() ->end() - ->end() - - ->arrayNode('user') + ->end() + ->end() + ->arrayNode('user') ->children() - ->scalarNode('uuid')->end() - ->booleanNode('is_acquian') - ->defaultValue(false) - ->end() + ->scalarNode('uuid')->end() + ->booleanNode('is_acquian') + ->defaultValue(false) ->end() - ->end() - - ->arrayNode('acsf_factories') + ->end() + ->end() + ->arrayNode('acsf_factories') ->useAttributeAsKey('url') ->normalizeKeys(false) ->arrayPrototype() - ->children() - ->arrayNode('users') - ->arrayPrototype() - ->children() - ->scalarNode('username')->end() - ->scalarNode('key')->end() - ->end() - ->end() - ->end() - ->scalarNode('url')->end() - ->scalarNode('active_user')->end() - ->end() + ->children() + ->arrayNode('users') + ->arrayPrototype() + ->children() + ->scalarNode('username')->end() + ->scalarNode('key')->end() ->end() - ->end() - - ->scalarNode('acsf_active_factory')->end() - - ->end() - ->validate() - ->ifTrue(function ($config) { - return is_array($config['keys']) && !empty($config['keys']) && !array_key_exists($config['acli_key'], $config['keys']); - }) - ->thenInvalid('acli_key must exist in keys'); + ->end() + ->end() + ->scalarNode('url')->end() + ->scalarNode('active_user')->end() + ->end() + ->end() + ->end() + ->scalarNode('acsf_active_factory')->end() + ->end() + ->validate() + ->ifTrue(function ($config) { + return is_array($config['keys']) && !empty($config['keys']) && !array_key_exists($config['acli_key'], $config['keys']); + }) + ->thenInvalid('acli_key must exist in keys'); return $treeBuilder; } } diff --git a/src/EventListener/ComposerScriptsListener.php b/src/EventListener/ComposerScriptsListener.php index b7b3ed796..3b0bb4bea 100644 --- a/src/EventListener/ComposerScriptsListener.php +++ b/src/EventListener/ComposerScriptsListener.php @@ -40,7 +40,10 @@ private function executeComposerScripts(ConsoleCommandEvent|ConsoleTerminateEven { /** @var CommandBase $command */ $command = $event->getCommand(); - if ($event->getInput()->hasOption('no-scripts') && $event->getInput()->getOption('no-scripts')) { + if ( + $event->getInput()->hasOption('no-scripts') && $event->getInput() + ->getOption('no-scripts') + ) { return; } // Only successful commands should be executed. @@ -52,11 +55,17 @@ private function executeComposerScripts(ConsoleCommandEvent|ConsoleTerminateEven // Replace colons with hyphens. E.g., pull:db becomes pull-db. $scriptName = $prefix . '-acli-' . str_replace(':', '-', $commandName); if (array_key_exists('scripts', $composerJson) && array_key_exists($scriptName, $composerJson['scripts'])) { - $event->getOutput()->writeln("Executing composer script `$scriptName` defined in `$composerJsonFilepath`", OutputInterface::VERBOSITY_VERBOSE); + $event->getOutput() + ->writeln("Executing composer script `$scriptName` defined in `$composerJsonFilepath`", OutputInterface::VERBOSITY_VERBOSE); $event->getOutput()->writeln($scriptName); - $command->localMachineHelper->execute(['composer', 'run-script', $scriptName]); + $command->localMachineHelper->execute([ + 'composer', + 'run-script', + $scriptName, + ]); } else { - $event->getOutput()->writeln("Notice: Composer script `$scriptName` does not exist in `$composerJsonFilepath`, skipping. This is not an error.", OutputInterface::VERBOSITY_VERBOSE); + $event->getOutput() + ->writeln("Notice: Composer script `$scriptName` does not exist in `$composerJsonFilepath`, skipping. This is not an error.", OutputInterface::VERBOSITY_VERBOSE); } } } diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index bb59dcb6b..1f6bdf01b 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -114,14 +114,14 @@ public function onConsoleError(ConsoleErrorEvent $event): void private function writeApplicationAliasHelp(): void { $this->helpMessages[] = "The messagesBgColor;options=bold>applicationUuid argument must be a valid UUID or unique application alias accessible to your Cloud Platform user." . PHP_EOL . PHP_EOL - . "An alias consists of an application name optionally prefixed with a hosting realm, e.g. messagesBgColor;fg=$this->messagesFgColor;options=bold>myapp or messagesBgColor;fg=$this->messagesFgColor;options=bold>prod.myapp." . PHP_EOL . PHP_EOL - . "Run messagesBgColor;options=bold>acli remote:aliases:list to see a list of all available aliases."; + . "An alias consists of an application name optionally prefixed with a hosting realm, e.g. messagesBgColor;fg=$this->messagesFgColor;options=bold>myapp or messagesBgColor;fg=$this->messagesFgColor;options=bold>prod.myapp." . PHP_EOL . PHP_EOL + . "Run messagesBgColor;options=bold>acli remote:aliases:list to see a list of all available aliases."; } private function writeSiteAliasHelp(): void { $this->helpMessages[] = "messagesBgColor;options=bold>environmentId can also be a site alias. E.g. messagesBgColor;fg=$this->messagesFgColor;options=bold>myapp.dev." . PHP_EOL - . "Run messagesBgColor;options=bold>acli remote:aliases:list to see a list of all available aliases."; + . "Run messagesBgColor;options=bold>acli remote:aliases:list to see a list of all available aliases."; } private function writeSupportTicketHelp(ConsoleErrorEvent $event): void diff --git a/src/Exception/AcquiaCliException.php b/src/Exception/AcquiaCliException.php index 515d1d659..5f436b5a1 100644 --- a/src/Exception/AcquiaCliException.php +++ b/src/Exception/AcquiaCliException.php @@ -24,7 +24,8 @@ public function __construct( 'code' => $code, 'message' => $rawMessage, ]; - Amplitude::getInstance()->queueEvent('Threw exception', $eventProperties); + Amplitude::getInstance() + ->queueEvent('Threw exception', $eventProperties); parent::__construct($this->interpolateString($rawMessage, $replacements), $code); } diff --git a/src/Helpers/DataStoreContract.php b/src/Helpers/DataStoreContract.php index 1173e41f1..ad58bbb1c 100644 --- a/src/Helpers/DataStoreContract.php +++ b/src/Helpers/DataStoreContract.php @@ -7,5 +7,6 @@ class DataStoreContract { public const SEND_TELEMETRY = 'send_telemetry'; + public const USER = 'user'; } diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index 696cbb433..1712bb36b 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -21,7 +21,8 @@ use function safe\file_get_contents; /** - * A helper for executing commands on the local client. A wrapper for 'exec' and 'passthru'. + * A helper for executing commands on the local client. A wrapper for 'exec' + * and 'passthru'. */ class LocalMachineHelper { @@ -48,16 +49,20 @@ public function __construct( /** * Check if a command exists. * - * This won't find aliases or shell built-ins, so use it mindfully (e.g. only - * for commands that you _know_ to be system commands). + * This won't find aliases or shell built-ins, so use it mindfully (e.g. + * only for commands that you _know_ to be system commands). */ public function commandExists(string $command): bool { if (array_key_exists($command, $this->installedBinaries)) { return $this->installedBinaries[$command]; } - $osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command]; - $exists = $this->execute($osCommand, null, null, false, null, null, false)->isSuccessful(); + $osCommand = OsInfo::isWindows() ? ['where', $command] : [ + 'which', + $command, + ]; + $exists = $this->execute($osCommand, null, null, false, null, null, false) + ->isSuccessful(); $this->installedBinaries[$command] = $exists; return $exists; } @@ -210,7 +215,8 @@ public function setIsTty(?bool $isTty): void */ public function writeFile(string $filename, string|StreamInterface $content): void { - $this->getFilesystem()->dumpFile($this->getLocalFilepath($filename), $content); + $this->getFilesystem() + ->dumpFile($this->getLocalFilepath($filename), $content); } /** @@ -265,11 +271,12 @@ public static function getConfigDir(): string * Get the project root directory for the working directory. * * This method assumes you are running `acli` in a directory containing a - * Drupal docroot either as a sibling or parent(N) of the working directory. + * Drupal docroot either as a sibling or parent(N) of the working + * directory. * - * Typically, the root directory would also be a Git repository root, though it - * doesn't have to be (such as for brand-new projects that haven't initialized - * Git yet). + * Typically, the root directory would also be a Git repository root, + * though it doesn't have to be (such as for brand-new projects that + * haven't initialized Git yet). */ public static function getProjectDir(): ?string { @@ -292,10 +299,12 @@ public static function getProjectDir(): ?string /** * Traverses file system upwards in search of a given file. * - * Begins searching for $file in $workingDirectory and climbs up directories + * Begins searching for $file in $workingDirectory and climbs up + * directories * $maxHeight times, repeating search. * - * @return bool|string FALSE if file was not found. Otherwise, the directory path containing the file. + * @return bool|string FALSE if file was not found. Otherwise, the + * directory path containing the file. */ private static function findDirectoryContainingFiles(string $workingDirectory, array $files, int $maxHeight = 10): bool|string { @@ -346,14 +355,15 @@ public function isBrowserAvailable(): bool /** * Starts a background browser/tab for the current site or a specified URL. * - * Exclude from mutation testing as we don't want real browser windows opened. + * Exclude from mutation testing as we don't want real browser windows + * opened. * - * @param string|null $uri Optional URI or site path to open in browser. If omitted, or if a site path - * is specified, the current site home page uri will be prepended if the site's - * hostname resolves. + * @param string|null $uri Optional URI or site path to open in browser. If + * omitted, or if a site path is specified, the current site home page + * uri will be prepended if the site's hostname resolves. * @param string|null $browser The command to run to launch a browser. - * @return bool TRUE if browser was opened. FALSE if browser was disabled by the user or a - * default browser could not be found. + * @return bool TRUE if browser was opened. FALSE if browser was disabled + * by the user or a default browser could not be found. * @infection-ignore-all */ public function startBrowser(string $uri = null, string $browser = null): bool diff --git a/src/Helpers/LoopHelper.php b/src/Helpers/LoopHelper.php index 5910425a7..bae589359 100644 --- a/src/Helpers/LoopHelper.php +++ b/src/Helpers/LoopHelper.php @@ -12,7 +12,8 @@ class LoopHelper { /** - * @param callable $statusCallback A TRUE return value will cause the loop to exit and call $doneCallback. + * @param callable $statusCallback A TRUE return value will cause the loop + * to exit and call $doneCallback. */ public static function getLoopy(OutputInterface $output, SymfonyStyle $io, string $spinnerMessage, callable $statusCallback, callable $doneCallback): void { diff --git a/src/Helpers/SshCommandTrait.php b/src/Helpers/SshCommandTrait.php index dd05f30f4..ae225ddf0 100644 --- a/src/Helpers/SshCommandTrait.php +++ b/src/Helpers/SshCommandTrait.php @@ -33,8 +33,8 @@ private function deleteSshKeyFromCloud(mixed $output, mixed $cloudKey = null): i $localFile->getRealPath(), $privateKeyPath, ]); - $this->io->success("Deleted $publicKeyPath and $privateKeyPath"); - return 0; + $this->io->success("Deleted $publicKeyPath and $privateKeyPath"); + return 0; } } } @@ -62,7 +62,10 @@ private function determineCloudKey(Client $acquiaCloudClient): object|array|null protected function findLocalSshKeys(): array { $finder = $this->localMachineHelper->getFinder(); - $finder->files()->in($this->sshDir)->name('*.pub')->ignoreUnreadableDirs(); + $finder->files() + ->in($this->sshDir) + ->name('*.pub') + ->ignoreUnreadableDirs(); return iterator_to_array($finder); } @@ -70,7 +73,8 @@ protected function promptWaitForSsh(SymfonyStyle $io): bool { $io->note("It may take an hour or more before the SSH key is installed on all of your application's servers. Create a Support ticket for further assistance."); $wait = $io->confirm("Would you like to wait until your key is installed on all of your application's servers?"); - Amplitude::getInstance()->queueEvent('User waited for SSH key upload', ['wait' => $wait]); + Amplitude::getInstance() + ->queueEvent('User waited for SSH key upload', ['wait' => $wait]); return $wait; } } diff --git a/src/Helpers/TelemetryHelper.php b/src/Helpers/TelemetryHelper.php index aab4aa901..56b5845d8 100644 --- a/src/Helpers/TelemetryHelper.php +++ b/src/Helpers/TelemetryHelper.php @@ -231,8 +231,9 @@ private function getDefaultUserData(): array /** * @infection-ignore-all - * Skipping infection testing for this because, it most cases, we expect that when a row from this array is changed - * it won't affect the return value. + * Skipping infection testing for this because, it most cases, we expect + * that when a row from this array is changed it won't affect the + * return value. * @return array * An array of providers and their associated environment variables. */ @@ -243,7 +244,7 @@ public static function getProviders(): array return [ 'lando' => ['LANDO'], 'ddev' => ['IS_DDEV_PROJECT'], - // Check Lando and DDEV first because the hijack AH_SITE_ENVIRONMENT. + // Check Lando and DDEV first because the hijack AH_SITE_ENVIRONMENT. 'acquia' => ['AH_SITE_ENVIRONMENT'], 'bamboo' => ['BAMBOO_BUILDNUMBER'], 'beanstalk' => ['BEANSTALK_ENVIRONMENT'], diff --git a/src/Kernel.php b/src/Kernel.php index 053bfa68b..aa1ecd558 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -51,11 +51,11 @@ protected function registerExtensionConfiguration(mixed $loader): void // Search for plugins. $finder = new Finder(); $extensions = $finder->files() - ->in([ - __DIR__ . '/../../', - ]) - ->depth(1) - ->name('acli.services.yml'); + ->in([ + __DIR__ . '/../../', + ]) + ->depth(1) + ->name('acli.services.yml'); foreach ($extensions as $extension) { $loader->load($extension->getRealPath()); } diff --git a/src/Output/Checklist.php b/src/Output/Checklist.php index c9c16ef83..aba78ca8b 100644 --- a/src/Output/Checklist.php +++ b/src/Output/Checklist.php @@ -86,7 +86,7 @@ public function updateProgressBar(string $updateMessage): void private function useSpinner(): bool { return $this->output instanceof ConsoleOutput - && (getenv('CI') !== 'true' || getenv('PHPUNIT_RUNNING')); + && (getenv('CI') !== 'true' || getenv('PHPUNIT_RUNNING')); } /** diff --git a/src/Output/Spinner/Spinner.php b/src/Output/Spinner/Spinner.php index 1817ae244..6e6ef4ff5 100644 --- a/src/Output/Spinner/Spinner.php +++ b/src/Output/Spinner/Spinner.php @@ -14,6 +14,7 @@ class Spinner { private const CHARS = ['⠏', '⠛', '⠹', '⢸', '⣰', '⣤', '⣆', '⡇']; + private const COLORS = [ 196, 196, @@ -188,7 +189,7 @@ public function interval(): float private function spinnerIsSupported(): bool { return $this->output instanceof ConsoleOutput - && (getenv('CI') !== 'true' || getenv('PHPUNIT_RUNNING')); + && (getenv('CI') !== 'true' || getenv('PHPUNIT_RUNNING')); } public function getProgressBar(): ProgressBar diff --git a/tests/phpunit/src/AcsfApi/AcsfServiceTest.php b/tests/phpunit/src/AcsfApi/AcsfServiceTest.php index 1640c8b3a..a955385b1 100644 --- a/tests/phpunit/src/AcsfApi/AcsfServiceTest.php +++ b/tests/phpunit/src/AcsfApi/AcsfServiceTest.php @@ -49,7 +49,11 @@ public function providerTestIsMachineAuthenticated(): array public function testIsMachineAuthenticated(array $envVars, bool $isAuthenticated): void { self::setEnvVars($envVars); - $clientService = new AcsfClientService(new AcsfConnectorFactory(['key' => null, 'secret' => null]), $this->prophet->prophesize(Application::class)->reveal(), $this->cloudCredentials); + $clientService = new AcsfClientService(new AcsfConnectorFactory([ + 'key' => null, + 'secret' => null, + ]), $this->prophet->prophesize(Application::class) + ->reveal(), $this->cloudCredentials); $this->assertEquals($isAuthenticated, $clientService->isMachineAuthenticated()); self::unsetEnvVars($envVars); } diff --git a/tests/phpunit/src/ApplicationTestBase.php b/tests/phpunit/src/ApplicationTestBase.php index 37be6f8c9..94f5d1fad 100644 --- a/tests/phpunit/src/ApplicationTestBase.php +++ b/tests/phpunit/src/ApplicationTestBase.php @@ -25,8 +25,10 @@ public function setUp(): void parent::setUp(); $this->kernel = new Kernel('dev', false); $this->kernel->boot(); - $this->kernel->getContainer()->set(CloudDataStore::class, $this->datastoreCloud); - $this->kernel->getContainer()->set(ClientService::class, $this->clientServiceProphecy->reveal()); + $this->kernel->getContainer() + ->set(CloudDataStore::class, $this->datastoreCloud); + $this->kernel->getContainer() + ->set(ClientService::class, $this->clientServiceProphecy->reveal()); $output = new BufferedOutput(); $this->kernel->getContainer()->set(OutputInterface::class, $output); } diff --git a/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php b/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php index 866f07ea8..3dba738ae 100644 --- a/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php +++ b/tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php @@ -63,7 +63,8 @@ public function testAccessToken(): void ); $connector = $connectorFactory->createConnector(); self::assertInstanceOf(AccessTokenConnector::class, $connector); - self::assertEquals(self::$accessToken, $connector->getAccessToken()->getToken()); + self::assertEquals(self::$accessToken, $connector->getAccessToken() + ->getToken()); $verb = 'get'; $path = 'api'; @@ -71,8 +72,9 @@ public function testAccessToken(): void // Make sure that new access tokens are fetched using the refresh token. $mockProvider = $this->prophet->prophesize(GenericProvider::class); $mockProvider->getAuthenticatedRequest($verb, ConnectorInterface::BASE_URI . $path, Argument::type(AccessTokenInterface::class)) - ->willReturn($this->prophet->prophesize(RequestInterface::class)->reveal()) - ->shouldBeCalled(); + ->willReturn($this->prophet->prophesize(RequestInterface::class) + ->reveal()) + ->shouldBeCalled(); $connector->setProvider($mockProvider->reveal()); $connector->createRequest($verb, $path); @@ -127,8 +129,8 @@ public function testMissingExpiryFile(): void } /** - * Validate that if both an access token and API key/secret pair are present, - * the pair is used. + * Validate that if both an access token and API key/secret pair are + * present, the pair is used. */ public function testConnector(): void { @@ -194,7 +196,10 @@ public function testIdeHeader(): void $clientService = new ClientService($connectorFactory, $this->application, $this->cloudCredentials); $client = $clientService->getClient(); $options = $client->getOptions(); - $this->assertEquals(['User-Agent' => [0 => 'acli/UNKNOWN'], 'X-Cloud-IDE-UUID' => IdeHelper::$remoteIdeUuid], $options['headers']); + $this->assertEquals([ + 'User-Agent' => [0 => 'acli/UNKNOWN'], + 'X-Cloud-IDE-UUID' => IdeHelper::$remoteIdeUuid, + ], $options['headers']); $this->prophet->checkPredictions(); IdeHelper::unsetCloudIdeEnvVars(); diff --git a/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php b/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php index 087cb3e91..ebd3f3b16 100644 --- a/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php +++ b/tests/phpunit/src/CloudApi/AcsfClientServiceTest.php @@ -15,6 +15,7 @@ class AcsfClientServiceTest extends TestBase { protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../assets/acsf-spec.json'; + protected string $apiCommandPrefix = 'acsf'; /** @@ -24,11 +25,19 @@ public function providerTestIsMachineAuthenticated(): array { return [ [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], + [ + 'ACLI_ACCESS_TOKEN' => null, + 'ACLI_KEY' => null, + 'ACLI_SECRET' => null, + ], false, ], [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], + [ + 'ACLI_ACCESS_TOKEN' => null, + 'ACLI_KEY' => 'key', + 'ACLI_SECRET' => null, + ], false, ], ]; @@ -41,7 +50,11 @@ public function testIsMachineAuthenticated(array $envVars, bool $isAuthenticated { self::setEnvVars($envVars); $cloudDatastore = $this->prophet->prophesize(CloudDataStore::class); - $clientService = new AcsfClientService(new AcsfConnectorFactory(['key' => null, 'secret' => null, 'accessToken' => null]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); + $clientService = new AcsfClientService(new AcsfConnectorFactory([ + 'accessToken' => null, + 'key' => null, + 'secret' => null, + ]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); $this->assertEquals($isAuthenticated, $clientService->isMachineAuthenticated()); $clientService->getClient(); self::unsetEnvVars($envVars); @@ -51,7 +64,11 @@ public function testEmbeddedItems(): void { putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=1'); $cloudDatastore = $this->prophet->prophesize(CloudDataStore::class); - $clientService = new AcsfClientService(new AcsfConnectorFactory(['key' => null, 'secret' => null, 'accessToken' => null]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); + $clientService = new AcsfClientService(new AcsfConnectorFactory([ + 'accessToken' => null, + 'key' => null, + 'secret' => null, + ]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); $client = $clientService->getClient(); $mockBody = ['_embedded' => ['items' => 'foo']]; $response = new Response(200, [], json_encode($mockBody)); @@ -63,7 +80,11 @@ public function testErrorMessage(): void { putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=1'); $cloudDatastore = $this->prophet->prophesize(CloudDataStore::class); - $clientService = new AcsfClientService(new AcsfConnectorFactory(['key' => null, 'secret' => null, 'accessToken' => null]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); + $clientService = new AcsfClientService(new AcsfConnectorFactory([ + 'accessToken' => null, + 'key' => null, + 'secret' => null, + ]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); $client = $clientService->getClient(); $mockBody = ['error' => 'foo', 'message' => 'bar']; $response = new Response(200, [], json_encode($mockBody)); @@ -76,7 +97,11 @@ public function testErrorCode(): void { putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=1'); $cloudDatastore = $this->prophet->prophesize(CloudDataStore::class); - $clientService = new AcsfClientService(new AcsfConnectorFactory(['key' => null, 'secret' => null, 'accessToken' => null]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); + $clientService = new AcsfClientService(new AcsfConnectorFactory([ + 'accessToken' => null, + 'key' => null, + 'secret' => null, + ]), $this->application, new AcsfCredentials($cloudDatastore->reveal())); $client = $clientService->getClient(); $mockBody = ['message' => 'bar']; $response = new Response(400, [], json_encode($mockBody)); diff --git a/tests/phpunit/src/CloudApi/ClientServiceTest.php b/tests/phpunit/src/CloudApi/ClientServiceTest.php index fbf31875a..8d0ae8b1c 100644 --- a/tests/phpunit/src/CloudApi/ClientServiceTest.php +++ b/tests/phpunit/src/CloudApi/ClientServiceTest.php @@ -19,19 +19,35 @@ public function providerTestIsMachineAuthenticated(): array { return [ [ - ['ACLI_ACCESS_TOKEN' => 'token', 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], + [ + 'ACLI_ACCESS_TOKEN' => 'token', + 'ACLI_KEY' => 'key', + 'ACLI_SECRET' => 'secret', + ], true, ], [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => 'secret'], + [ + 'ACLI_ACCESS_TOKEN' => null, + 'ACLI_KEY' => 'key', + 'ACLI_SECRET' => 'secret', + ], true, ], [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => null, 'ACLI_SECRET' => null], + [ + 'ACLI_ACCESS_TOKEN' => null, + 'ACLI_KEY' => null, + 'ACLI_SECRET' => null, + ], false, ], [ - ['ACLI_ACCESS_TOKEN' => null, 'ACLI_KEY' => 'key', 'ACLI_SECRET' => null], + [ + 'ACLI_ACCESS_TOKEN' => null, + 'ACLI_KEY' => 'key', + 'ACLI_SECRET' => null, + ], false, ], ]; @@ -44,7 +60,11 @@ public function testIsMachineAuthenticated(array $envVars, bool $isAuthenticated { self::setEnvVars($envVars); $cloudDatastore = $this->prophet->prophesize(CloudDataStore::class); - $clientService = new ClientService(new ConnectorFactory(['key' => null, 'secret' => null, 'accessToken' => null]), $this->application, new CloudCredentials($cloudDatastore->reveal())); + $clientService = new ClientService(new ConnectorFactory([ + 'accessToken' => null, + 'key' => null, + 'secret' => null, + ]), $this->application, new CloudCredentials($cloudDatastore->reveal())); $this->assertEquals($isAuthenticated, $clientService->isMachineAuthenticated()); self::unsetEnvVars($envVars); } diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index 15a7a868e..285f52ef0 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -193,14 +193,20 @@ protected function createMockGitConfigFile(): void */ protected function removeMockGitConfig(): void { - $this->fs->remove([$this->getTargetGitConfigFixture(), dirname($this->getTargetGitConfigFixture())]); + $this->fs->remove([ + $this->getTargetGitConfigFixture(), + dirname($this->getTargetGitConfigFixture()), + ]); } protected function mockReadIdePhpVersion(string $phpVersion = '7.1'): LocalMachineHelper|ObjectProphecy { $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->getLocalFilepath(Path::join($this->dataDir, 'acquia-cli.json'))->willReturn(Path::join($this->dataDir, 'acquia-cli.json')); - $localMachineHelper->readFile('/home/ide/configs/php/.version')->willReturn("$phpVersion\n")->shouldBeCalled(); + $localMachineHelper->getLocalFilepath(Path::join($this->dataDir, 'acquia-cli.json')) + ->willReturn(Path::join($this->dataDir, 'acquia-cli.json')); + $localMachineHelper->readFile('/home/ide/configs/php/.version') + ->willReturn("$phpVersion\n") + ->shouldBeCalled(); return $localMachineHelper; } @@ -211,13 +217,13 @@ protected function mockReadIdePhpVersion(string $phpVersion = '7.1'): LocalMachi protected static function inputChooseEnvironment(): array { return [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: self::$INPUT_DEFAULT_CHOICE, ]; } @@ -254,8 +260,8 @@ protected function mockGetEnvironments(): object 'get', "/environments/" . $environmentResponse->id ) - ->willReturn($environmentResponse) - ->shouldBeCalled(); + ->willReturn($environmentResponse) + ->shouldBeCalled(); return $environmentResponse; } @@ -271,8 +277,8 @@ public function mockAcsfEnvironmentsRequest( 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn($environmentsResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($environmentsResponse->_embedded->items) + ->shouldBeCalled(); return $environmentsResponse; } @@ -284,7 +290,9 @@ protected function mockGetAcsfSites(mixed $sshHelper): array { $acsfMultisiteFetchProcess = $this->mockProcess(); $multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/multisite-config.json')); - $acsfMultisiteFetchProcess->getOutput()->willReturn($multisiteConfig)->shouldBeCalled(); + $acsfMultisiteFetchProcess->getOutput() + ->willReturn($multisiteConfig) + ->shouldBeCalled(); $sshHelper->executeCommand( Argument::type('string'), ['cat', '/var/www/site-php/profserv2.01dev/multisite-config.json'], @@ -296,7 +304,9 @@ protected function mockGetAcsfSites(mixed $sshHelper): array protected function mockGetCloudSites(mixed $sshHelper, mixed $environment): void { $cloudMultisiteFetchProcess = $this->mockProcess(); - $cloudMultisiteFetchProcess->getOutput()->willReturn("\nbar\ndefault\nfoo\n")->shouldBeCalled(); + $cloudMultisiteFetchProcess->getOutput() + ->willReturn("\nbar\ndefault\nfoo\n") + ->shouldBeCalled(); $parts = explode('.', $environment->ssh_url); $sitegroup = reset($parts); $sshHelper->executeCommand( @@ -336,8 +346,8 @@ static function (mixed $databaseResponse) { 'get', "/environments/{$environmentsResponse->id}/databases" ) - ->willReturn($databasesResponse) - ->shouldBeCalled(); + ->willReturn($databasesResponse) + ->shouldBeCalled(); return $databasesResponse; } @@ -361,15 +371,15 @@ protected function mockDatabaseBackupsResponse( 'get', "/environments/{$environmentsResponse->id}/databases/$dbName/backups" ) - ->willReturn($databaseBackupsResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($databaseBackupsResponse->_embedded->items) + ->shouldBeCalled(); } else { $this->clientProphecy->request( 'get', "/environments/{$environmentsResponse->id}/databases/$dbName/backups" ) - ->willReturn([], $databaseBackupsResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn([], $databaseBackupsResponse->_embedded->items) + ->shouldBeCalled(); } return $databaseBackupsResponse; @@ -382,8 +392,8 @@ protected function mockDownloadBackupResponse( ): void { $stream = $this->prophet->prophesize(StreamInterface::class); $this->clientProphecy->stream('get', "/environments/{$environmentsResponse->id}/databases/{$dbName}/backups/{$backupId}/actions/download", []) - ->willReturn($stream->reveal()) - ->shouldBeCalled(); + ->willReturn($stream->reveal()) + ->shouldBeCalled(); } protected function mockDatabaseBackupCreateResponse( @@ -392,8 +402,8 @@ protected function mockDatabaseBackupCreateResponse( ): mixed { $backupCreateResponse = $this->getMockResponseFromSpec('/environments/{environmentId}/databases/{databaseName}/backups', 'post', 202)->{'Creating backup'}->value; $this->clientProphecy->request('post', "/environments/$environmentsResponse->id/databases/{$dbName}/backups") - ->willReturn($backupCreateResponse) - ->shouldBeCalled(); + ->willReturn($backupCreateResponse) + ->shouldBeCalled(); return $backupCreateResponse; } @@ -406,12 +416,14 @@ protected function mockNotificationResponseFromObject(object $responseWithNotifi protected function mockCreateMySqlDumpOnLocal(ObjectProphecy $localMachineHelper, bool $printOutput = true): void { - $localMachineHelper->checkRequiredBinariesExist(["mysqldump", "gzip"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["mysqldump", "gzip"]) + ->shouldBeCalled(); $process = $this->mockProcess(); $process->getOutput()->willReturn(''); $command = 'MYSQL_PWD=drupal mysqldump --host=localhost --user=drupal drupal | pv --rate --bytes | gzip -9 > ' . sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz'; - $localMachineHelper->executeFromCmd($command, Argument::type('callable'), null, $printOutput)->willReturn($process->reveal()) - ->shouldBeCalled(); + $localMachineHelper->executeFromCmd($command, Argument::type('callable'), null, $printOutput) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecutePvExists( @@ -428,9 +440,9 @@ protected function mockExecuteGlabExists( ObjectProphecy $localMachineHelper ): void { $localMachineHelper - ->commandExists('glab') - ->willReturn(true) - ->shouldBeCalled(); + ->commandExists('glab') + ->willReturn(true) + ->shouldBeCalled(); } /** @@ -441,13 +453,14 @@ protected function setUpdateClient(int $statusCode = 200): void /** @var ObjectProphecy|\GuzzleHttp\Psr7\Response $guzzleResponse */ $guzzleResponse = $this->prophet->prophesize(Response::class); $stream = $this->prophet->prophesize(StreamInterface::class); - $stream->__toString()->willReturn(file_get_contents(Path::join(__DIR__, '..', '..', 'fixtures', 'github-releases.json'))); + $stream->__toString() + ->willReturn(file_get_contents(Path::join(__DIR__, '..', '..', 'fixtures', 'github-releases.json'))); $guzzleResponse->getBody()->willReturn($stream->reveal()); $guzzleResponse->getReasonPhrase()->willReturn(''); $guzzleResponse->getStatusCode()->willReturn($statusCode); $guzzleClient = $this->prophet->prophesize(Client::class); $guzzleClient->get('https://api.github.com/repos/acquia/cli/releases') - ->willReturn($guzzleResponse->reveal()); + ->willReturn($guzzleResponse->reveal()); $this->command->setUpdateClient($guzzleClient->reveal()); } @@ -463,17 +476,17 @@ protected function mockPollCloudViaSsh(array $environmentsResponse, bool $ssh = // Mock Git. $urlParts = explode(':', $environmentsResponse[0]->vcs->url); $sshHelper->executeCommand($urlParts[0], ['ls'], false) - ->willReturn($gitProcess->reveal()) - ->shouldBeCalled(); + ->willReturn($gitProcess->reveal()) + ->shouldBeCalled(); if ($ssh) { // Mock non-prod. $sshHelper->executeCommand($environmentsResponse[0]->ssh_url, ['ls'], false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); // Mock prod. $sshHelper->executeCommand($environmentsResponse[1]->ssh_url, ['ls'], false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } return $sshHelper; } @@ -485,8 +498,8 @@ protected function mockPollCloudGitViaSsh(object $environmentResponse): ObjectPr $process->getExitCode()->willReturn(128); $sshHelper = $this->mockSshHelper(); $sshHelper->executeCommand($environmentResponse->vcs->url, ['ls'], false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); return $sshHelper; } @@ -504,7 +517,8 @@ protected function mockGetLocalSshKey(mixed $localMachineHelper, mixed $fileSyst $file->getFileName()->willReturn($fileName); $file->getRealPath()->willReturn('somepath'); $localMachineHelper->readFile('somepath')->willReturn($publicKey); - $finder->getIterator()->willReturn(new \ArrayIterator([$file->reveal()])); + $finder->getIterator() + ->willReturn(new \ArrayIterator([$file->reveal()])); $localMachineHelper->getFinder()->willReturn($finder); return $fileName; @@ -669,8 +683,8 @@ protected function mockGitLabPermissionsRequest(mixed $applicationUuid): array $permission->name = "administer environment variables on non-prod"; $permissions[] = $permission; $this->clientProphecy->request('get', "/applications/{$applicationUuid}/permissions") - ->willReturn($permissions) - ->shouldBeCalled(); + ->willReturn($permissions) + ->shouldBeCalled(); return $permissions; } @@ -678,9 +692,9 @@ protected function mockGetGitLabProjects(mixed $applicationUuid, mixed $gitlabPr { $projects = $this->prophet->prophesize(Projects::class); $projects->all(['search' => $applicationUuid]) - ->willReturn($mockedGitlabProjects); + ->willReturn($mockedGitlabProjects); $projects->all() - ->willReturn([$this->getMockedGitLabProject($gitlabProjectId)]); + ->willReturn([$this->getMockedGitLabProject($gitlabProjectId)]); return $projects; } @@ -726,7 +740,7 @@ final public static function assertStringContainsStringIgnoringLineEndings(strin $haystack = strtr( $haystack, [ - "\r" => "\n", + "\r" => "\n", "\r\n" => "\n", ] ); diff --git a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php index 6790e484e..8a423d920 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php @@ -38,13 +38,16 @@ protected function createCommand(): CommandBase public function testAcsfCommandExecutionForHttpPostWithMultipleDataTypes(): void { $mockBody = $this->getMockResponseFromSpec('/api/v1/groups/{group_id}/members', 'post', '200'); - $this->clientProphecy->request('post', '/api/v1/groups/1/members')->willReturn($mockBody)->shouldBeCalled(); - $this->clientProphecy->addOption('json', ["uids" => ["1", "2", "3"]])->shouldBeCalled(); + $this->clientProphecy->request('post', '/api/v1/groups/1/members') + ->willReturn($mockBody) + ->shouldBeCalled(); + $this->clientProphecy->addOption('json', ["uids" => ["1", "2", "3"]]) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('acsf:groups:add-members'); $this->executeCommand([ 'uids' => '1,2,3', ], [ - // group_id. + // group_id. '1', ]); @@ -55,11 +58,14 @@ public function testAcsfCommandExecutionForHttpPostWithMultipleDataTypes(): void public function testAcsfCommandExecutionBool(): void { $mockBody = $this->getMockResponseFromSpec('/api/v1/update/pause', 'post', '200'); - $this->clientProphecy->request('post', '/api/v1/update/pause')->willReturn($mockBody)->shouldBeCalled(); - $this->clientProphecy->addOption('json', ["pause" => true])->shouldBeCalled(); + $this->clientProphecy->request('post', '/api/v1/update/pause') + ->willReturn($mockBody) + ->shouldBeCalled(); + $this->clientProphecy->addOption('json', ["pause" => true]) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('acsf:updates:pause'); $this->executeCommand([], [ - // Pause. + // Pause. '1', ]); @@ -70,7 +76,9 @@ public function testAcsfCommandExecutionForHttpGet(): void { $mockBody = $this->getMockResponseFromSpec('/api/v1/audit', 'get', '200'); $this->clientProphecy->addQuery('limit', '1')->shouldBeCalled(); - $this->clientProphecy->request('get', '/api/v1/audit')->willReturn($mockBody)->shouldBeCalled(); + $this->clientProphecy->request('get', '/api/v1/audit') + ->willReturn($mockBody) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('acsf:info:audit-events-find'); // Our mock Client doesn't actually return a limited dataset, but we still assert it was passed added to the // client's query correctly. @@ -90,12 +98,70 @@ public function testAcsfCommandExecutionForHttpGet(): void public function providerTestAcsfCommandExecutionForHttpGetMultiple(): array { return [ - ['get', '/api/v1/audit', '/api/v1/audit', 'acsf:info:audit-events-find', [], []], - ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91,81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], - ['post', '/api/v1/sites', '/api/v1/sites', 'acsf:sites:create', ['site_name' => 'foobar', '--stack_id' => '1', 'group_ids' => ['91','81']], ['site_name' => 'foobar', 'stack_id' => '1', 'group_ids' => [91, 81]]], - ['post', '/api/v1/sites/{site_id}/backup', '/api/v1/sites/1/backup', 'acsf:sites:backup', ['--label' => 'foo', 'site_id' => '1'], ['label' => 'foo']], - ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1'], ['group_id' => 'foo', 'uids' => 1]], - ['post', '/api/v1/groups/{group_id}/members', '/api/v1/groups/2/members', 'acsf:groups:add-members', ['group_id' => '2', 'uids' => '1,3'], ['group_id' => 'foo', 'uids' => [1, 3]]], + [ + 'get', + '/api/v1/audit', + '/api/v1/audit', + 'acsf:info:audit-events-find', + [], + [], + ], + [ + 'post', + '/api/v1/sites', + '/api/v1/sites', + 'acsf:sites:create', + [ + '--stack_id' => '1', + 'group_ids' => ['91,81'], + 'site_name' => 'foobar', + ], + [ + 'group_ids' => [91, 81], + 'site_name' => 'foobar', + 'stack_id' => '1', + ], + ], + [ + 'post', + '/api/v1/sites', + '/api/v1/sites', + 'acsf:sites:create', + [ + '--stack_id' => '1', + 'group_ids' => ['91', '81'], + 'site_name' => 'foobar', + ], + [ + 'group_ids' => [91, 81], + 'site_name' => 'foobar', + 'stack_id' => '1', + ], + ], + [ + 'post', + '/api/v1/sites/{site_id}/backup', + '/api/v1/sites/1/backup', + 'acsf:sites:backup', + ['--label' => 'foo', 'site_id' => '1'], + ['label' => 'foo'], + ], + [ + 'post', + '/api/v1/groups/{group_id}/members', + '/api/v1/groups/2/members', + 'acsf:groups:add-members', + ['group_id' => '2', 'uids' => '1'], + ['group_id' => 'foo', 'uids' => 1], + ], + [ + 'post', + '/api/v1/groups/{group_id}/members', + '/api/v1/groups/2/members', + 'acsf:groups:add-members', + ['group_id' => '2', 'uids' => '1,3'], + ['group_id' => 'foo', 'uids' => [1, 3]], + ], ]; } @@ -105,7 +171,9 @@ public function providerTestAcsfCommandExecutionForHttpGetMultiple(): array public function testAcsfCommandExecutionForHttpGetMultiple(string $method, string $specPath, string $path, string $command, array $arguments = [], array $jsonArguments = []): void { $mockBody = $this->getMockResponseFromSpec($specPath, $method, '200'); - $this->clientProphecy->request($method, $path)->willReturn($mockBody)->shouldBeCalled(); + $this->clientProphecy->request($method, $path) + ->willReturn($mockBody) + ->shouldBeCalled(); foreach ($jsonArguments as $argumentName => $value) { $this->clientProphecy->addOption('json', [$argumentName => $value]); } @@ -121,11 +189,12 @@ public function testAcsfCommandExecutionForHttpGetMultiple(string $method, strin public function testAcsfUnauthenticatedFailure(): void { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockConfigFiles(); $inputs = [ - // Would you like to share anonymous performance usage and data? + // Would you like to share anonymous performance usage and data? 'n', ]; $this->expectException(AcquiaCliException::class); @@ -140,9 +209,9 @@ protected function setClientProphecies(): void $this->clientProphecy->addOption('debug', Argument::type(OutputInterface::class)); $this->clientServiceProphecy = $this->prophet->prophesize(AcsfClientService::class); $this->clientServiceProphecy->getClient() - ->willReturn($this->clientProphecy->reveal()); + ->willReturn($this->clientProphecy->reveal()); $this->clientServiceProphecy->isMachineAuthenticated() - ->willReturn(true); + ->willReturn(true); } protected function getCommandFactory(): CommandFactoryInterface diff --git a/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php index b5e777d50..f4c16c8ca 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php @@ -27,19 +27,19 @@ protected function createCommand(): CommandBase public function providerTestAuthLoginCommand(): array { return [ - // Data set 0. + // Data set 0. [ - // $machineIsAuthenticated + // $machineIsAuthenticated false, - // $inputs + // $inputs [ - // Would you like to share anonymous performance usage and data? (yes/no) [yes]. + // Would you like to share anonymous performance usage and data? (yes/no) [yes]. 'yes', - // Enter the full URL of the factory. + // Enter the full URL of the factory. $this->acsfCurrentFactoryUrl, - // Enter a value for username. + // Enter a value for username. $this->acsfUsername, - // Enter a value for key. + // Enter a value for key. $this->acsfKey, ], // No arguments, all interactive. @@ -49,17 +49,17 @@ public function providerTestAuthLoginCommand(): array ], // Data set 1. [ - // $machineIsAuthenticated + // $machineIsAuthenticated false, - // $inputs + // $inputs [], - // Arguments. + // Arguments. [ - // Enter the full URL of the factory. + // Enter the full URL of the factory. '--factory-url' => $this->acsfCurrentFactoryUrl, - // Enter a value for key. + // Enter a value for key. '--key' => $this->acsfKey, - // Enter a value for username. + // Enter a value for username. '--username' => $this->acsfUsername, ], // Output to assert. @@ -69,13 +69,13 @@ public function providerTestAuthLoginCommand(): array ], // Data set 2. [ - // $machineIsAuthenticated + // $machineIsAuthenticated true, - // $inputs + // $inputs [ - // Choose a factory to log in to. + // Choose a factory to log in to. $this->acsfCurrentFactoryUrl, - // Choose which user to log in as. + // Choose which user to log in as. $this->acsfUsername, ], // Arguments. @@ -95,7 +95,8 @@ public function providerTestAuthLoginCommand(): array public function testAcsfAuthLoginCommand(bool $machineIsAuthenticated, array $inputs, array $args, string $outputToAssert, array $config = []): void { if (!$machineIsAuthenticated) { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); } else { $this->removeMockCloudConfigFile(); diff --git a/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php b/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php index 560b6c18f..82fe5d22d 100644 --- a/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php +++ b/tests/phpunit/src/Commands/Acsf/AcsfAuthLogoutCommandTest.php @@ -27,20 +27,20 @@ protected function createCommand(): CommandBase public function providerTestAuthLogoutCommand(): array { return [ - // Data set 0. + // Data set 0. [ - // $machineIsAuthenticated + // $machineIsAuthenticated false, - // $inputs + // $inputs [], ], // Data set 1. [ - // $machineIsAuthenticated + // $machineIsAuthenticated true, - // $inputs + // $inputs [ - // Choose a Factory to logout of. + // Choose a Factory to logout of. 0, ], // $config. @@ -55,7 +55,8 @@ public function providerTestAuthLogoutCommand(): array public function testAcsfAuthLogoutCommand(bool $machineIsAuthenticated, array $inputs, array $config = []): void { if (!$machineIsAuthenticated) { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); } else { $this->createMockCloudConfigFile($config); diff --git a/tests/phpunit/src/Commands/Api/ApiCommandTest.php b/tests/phpunit/src/Commands/Api/ApiCommandTest.php index 557e2ff01..a7f9e9712 100644 --- a/tests/phpunit/src/Commands/Api/ApiCommandTest.php +++ b/tests/phpunit/src/Commands/Api/ApiCommandTest.php @@ -82,21 +82,24 @@ public function testArgumentsInteractionValidationFormat(): void public function testApiCommandErrorResponse(): void { $invalidUuid = '257a5440-22c3-49d1-894d-29497a1cf3b9'; - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:applications:find'); $mockBody = $this->getMockResponseFromSpec($this->command->getPath(), $this->command->getMethod(), '404'); - $this->clientProphecy->request('get', '/applications/' . $invalidUuid)->willThrow(new ApiErrorException($mockBody))->shouldBeCalled(); + $this->clientProphecy->request('get', '/applications/' . $invalidUuid) + ->willThrow(new ApiErrorException($mockBody)) + ->shouldBeCalled(); // ApiCommandBase::convertApplicationAliastoUuid() will try to convert the invalid string to a uuid: $this->clientProphecy->addQuery('filter', 'hosting=@*:' . $invalidUuid); $this->clientProphecy->request('get', '/applications')->willReturn([]); $this->executeCommand(['applicationUuid' => $invalidUuid], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: '0', - // Would you like to link the Cloud application Sample application to this repository? + // Would you like to link the Cloud application Sample application to this repository? 'n', ]); @@ -109,10 +112,13 @@ public function testApiCommandErrorResponse(): void public function testApiCommandExecutionForHttpGet(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $mockBody = $this->getMockResponseFromSpec('/account/ssh-keys', 'get', '200'); $this->clientProphecy->addQuery('limit', '1')->shouldBeCalled(); - $this->clientProphecy->request('get', '/account/ssh-keys')->willReturn($mockBody->{'_embedded'}->items)->shouldBeCalled(); + $this->clientProphecy->request('get', '/account/ssh-keys') + ->willReturn($mockBody->{'_embedded'}->items) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:accounts:ssh-keys-list'); // Our mock Client doesn't actually return a limited dataset, but we still assert it was passed added to the // client's query correctly. @@ -144,16 +150,17 @@ public function testObjectParam(): void public function testInferApplicationUuidArgument(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $applications = $this->mockRequest('getApplications'); $application = $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); $this->command = $this->getApiCommandByName('api:applications:find'); $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: '0', - // Would you like to link the Cloud application Sample application to this repository? + // Would you like to link the Cloud application Sample application to this repository? 'n', ]); @@ -182,13 +189,15 @@ public function providerTestConvertApplicationAliasToUuidArgument(): array public function testConvertApplicationAliasToUuidArgument(bool $support): void { ClearCacheCommand::clearCaches(); - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $tamper = function (&$response): void { unset($response[1]); }; $applications = $this->mockRequest('getApplications', null, null, null, $tamper); $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:applications:find'); $alias = 'devcloud2'; $tamper = null; @@ -201,11 +210,11 @@ public function testConvertApplicationAliasToUuidArgument(bool $support): void $this->mockRequest('getAccount', null, null, null, $tamper); $this->executeCommand(['applicationUuid' => $alias], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the Cloud application Sample application to this repository? + // Would you like to link the Cloud application Sample application to this repository? 'n', ]); @@ -217,7 +226,8 @@ public function testConvertApplicationAliasToUuidArgument(bool $support): void public function testConvertInvalidApplicationAliasToUuidArgument(): void { $this->mockApplicationsRequest(0); - $this->clientProphecy->addQuery('filter', 'hosting=@*:invalidalias')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:invalidalias') + ->shouldBeCalled(); $this->mockRequest('getAccount'); $this->command = $this->getApiCommandByName('api:applications:find'); $alias = 'invalidalias'; @@ -233,7 +243,8 @@ public function testConvertNonUniqueApplicationAliasToUuidArgument(): void { ClearCacheCommand::clearCaches(); $this->mockApplicationsRequest(2, false); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->mockRequest('getAccount'); $this->command = $this->getApiCommandByName('api:applications:find'); $alias = 'devcloud2'; @@ -249,9 +260,11 @@ public function testConvertNonUniqueApplicationAliasToUuidArgument(): void */ public function testConvertApplicationAliasWithRealmToUuidArgument(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $this->mockApplicationsRequest(1, false); - $this->clientProphecy->addQuery('filter', 'hosting=@devcloud:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@devcloud:devcloud2') + ->shouldBeCalled(); $this->mockApplicationRequest(); $this->mockRequest('getAccount'); $this->command = $this->getApiCommandByName('api:applications:find'); @@ -265,24 +278,28 @@ public function testConvertApplicationAliasWithRealmToUuidArgument(): void public function testConvertEnvironmentAliasToUuidArgument(): void { ClearCacheCommand::clearCaches(); - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $applicationsResponse = $this->mockApplicationsRequest(1); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->mockEnvironmentsRequest($applicationsResponse); $this->mockRequest('getAccount'); $response = $this->getMockEnvironmentResponse(); - $this->clientProphecy->request('get', '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470')->willReturn($response)->shouldBeCalled(); + $this->clientProphecy->request('get', '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470') + ->willReturn($response) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:environments:find'); $alias = 'devcloud2.dev'; $this->executeCommand(['environmentId' => $alias], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: '0', - // Would you like to link the Cloud application Sample application to this repository? + // Would you like to link the Cloud application Sample application to this repository? 'n', ]); @@ -298,7 +315,8 @@ public function testConvertInvalidEnvironmentAliasToUuidArgument(): void { ClearCacheCommand::clearCaches(); $applicationsResponse = $this->mockApplicationsRequest(1); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->mockEnvironmentsRequest($applicationsResponse); $this->mockRequest('getAccount'); $this->command = $this->getApiCommandByName('api:environments:find'); @@ -310,13 +328,17 @@ public function testConvertInvalidEnvironmentAliasToUuidArgument(): void public function testApiCommandExecutionForHttpPost(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $mockRequestArgs = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $mockResponseBody = $this->getMockResponseFromSpec('/account/ssh-keys', 'post', '202'); foreach ($mockRequestArgs as $name => $value) { - $this->clientProphecy->addOption('json', [$name => $value])->shouldBeCalled(); + $this->clientProphecy->addOption('json', [$name => $value]) + ->shouldBeCalled(); } - $this->clientProphecy->request('post', '/account/ssh-keys')->willReturn($mockResponseBody)->shouldBeCalled(); + $this->clientProphecy->request('post', '/account/ssh-keys') + ->willReturn($mockResponseBody) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:accounts:ssh-key-create'); $this->executeCommand($mockRequestArgs); @@ -329,15 +351,19 @@ public function testApiCommandExecutionForHttpPost(): void public function testApiCommandExecutionForHttpPut(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $mockRequestOptions = $this->getMockRequestBodyFromSpec('/environments/{environmentId}', 'put'); $mockRequestOptions['max_input_vars'] = 1001; $mockResponseBody = $this->getMockEnvironmentResponse('put', '202'); foreach ($mockRequestOptions as $name => $value) { - $this->clientProphecy->addOption('json', [$name => $value])->shouldBeCalled(); + $this->clientProphecy->addOption('json', [$name => $value]) + ->shouldBeCalled(); } - $this->clientProphecy->request('put', '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470')->willReturn($mockResponseBody)->shouldBeCalled(); + $this->clientProphecy->request('put', '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470') + ->willReturn($mockResponseBody) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:environments:update'); $options = []; @@ -363,11 +389,36 @@ public function providerTestApiCommandDefinitionParameters(): array { $apiAccountsSshKeysListUsage = '--from="-7d" --to="-1d" --sort="field1,-field2" --limit="10" --offset="10"'; return [ - ['0', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:accounts:ssh-keys-list', 'get', $apiAccountsSshKeysListUsage], - ['1', 'api:environments:domain-clear-caches', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 example.com'], - ['1', 'api:applications:find', 'get', 'da1c0a8e-ff69-45db-88fc-acd6d2affbb7'], + [ + '0', + 'api:accounts:ssh-keys-list', + 'get', + $apiAccountsSshKeysListUsage, + ], + [ + '1', + 'api:accounts:ssh-keys-list', + 'get', + $apiAccountsSshKeysListUsage, + ], + [ + '1', + 'api:accounts:ssh-keys-list', + 'get', + $apiAccountsSshKeysListUsage, + ], + [ + '1', + 'api:environments:domain-clear-caches', + 'post', + '12-d314739e-296f-11e9-b210-d663bd873d93 example.com', + ], + [ + '1', + 'api:applications:find', + 'get', + 'da1c0a8e-ff69-45db-88fc-acd6d2affbb7', + ], ['1', 'api:applications:find', 'get', 'myapp'], ]; } @@ -403,10 +454,14 @@ public function testApiCommandDefinitionParameters(string $useSpecCache, string public function testModifiedParameterDescriptions(): void { $this->command = $this->getApiCommandByName('api:environments:domain-status-find'); - $this->assertStringContainsString('You may also use an environment alias', $this->command->getDefinition()->getArgument('environmentId')->getDescription()); + $this->assertStringContainsString('You may also use an environment alias', $this->command->getDefinition() + ->getArgument('environmentId') + ->getDescription()); $this->command = $this->getApiCommandByName('api:applications:find'); - $this->assertStringContainsString('You may also use an application alias or omit the argument', $this->command->getDefinition()->getArgument('applicationUuid')->getDescription()); + $this->assertStringContainsString('You may also use an application alias or omit the argument', $this->command->getDefinition() + ->getArgument('applicationUuid') + ->getDescription()); } /** @@ -415,8 +470,16 @@ public function testModifiedParameterDescriptions(): void public function providerTestApiCommandDefinitionRequestBody(): array { return [ - ['api:accounts:ssh-key-create', 'post', 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChwPHzTTDKDpSbpa2+d22LcbQmsw92eLsUK3Fmei1fiGDkd34NsYCN8m7lsi3NbvdMS83CtPQPWiCveYPzFs1/hHc4PYj8opD2CNnr5iWVVbyaulCYHCgVv4aB/ojcexg8q483A4xJeF15TiCr/gu34rK6ucTvC/tn/rCwJBudczvEwt0klqYwv8Cl/ytaQboSuem5KgSjO3lMrb6CWtfSNhE43ZOw+UBFBqxIninN868vGMkIv9VY34Pwj54rPn/ItQd6Ef4B0KHHaGmzK0vfP+AK7FxNMoHnj3iYT33KZNqtDozdn5tYyH/bThPebEtgqUn+/w5l6wZIC/8zzvls/127ngHk+jNa0PlNyS2TxhPUK4NaPHIEnnrlp07JEYC4ImcBjaYCWAdcTcUkcJjwZQkN4bGmyO9cjICH98SdLD/HxqzTHeaYDbAX/Hu9HfaBb5dXLWsjw3Xc6hoVnUUZbMQyfgb0KgxDLh92eNGxJkpZiL0VDNOWCxDWsNpzwhLNkLqCvI6lyxiLaUzvJAk6dPaRhExmCbU1lDO2eR0FdSwC1TEhJOT9eDIK1r2hztZKs2oa5FNFfB/IFHVWasVFC9N2h/r/egB5zsRxC9MqBLRBq95NBxaRSFng6ML5WZSw41Qi4C/JWVm89rdj2WqScDHYyAdwyyppWU4T5c9Fmw== example@example.com"'], - ['api:environments:file-copy', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 --source="14-0c7e79ab-1c4a-424e-8446-76ae8be7e851"'], + [ + 'api:accounts:ssh-key-create', + 'post', + 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChwPHzTTDKDpSbpa2+d22LcbQmsw92eLsUK3Fmei1fiGDkd34NsYCN8m7lsi3NbvdMS83CtPQPWiCveYPzFs1/hHc4PYj8opD2CNnr5iWVVbyaulCYHCgVv4aB/ojcexg8q483A4xJeF15TiCr/gu34rK6ucTvC/tn/rCwJBudczvEwt0klqYwv8Cl/ytaQboSuem5KgSjO3lMrb6CWtfSNhE43ZOw+UBFBqxIninN868vGMkIv9VY34Pwj54rPn/ItQd6Ef4B0KHHaGmzK0vfP+AK7FxNMoHnj3iYT33KZNqtDozdn5tYyH/bThPebEtgqUn+/w5l6wZIC/8zzvls/127ngHk+jNa0PlNyS2TxhPUK4NaPHIEnnrlp07JEYC4ImcBjaYCWAdcTcUkcJjwZQkN4bGmyO9cjICH98SdLD/HxqzTHeaYDbAX/Hu9HfaBb5dXLWsjw3Xc6hoVnUUZbMQyfgb0KgxDLh92eNGxJkpZiL0VDNOWCxDWsNpzwhLNkLqCvI6lyxiLaUzvJAk6dPaRhExmCbU1lDO2eR0FdSwC1TEhJOT9eDIK1r2hztZKs2oa5FNFfB/IFHVWasVFC9N2h/r/egB5zsRxC9MqBLRBq95NBxaRSFng6ML5WZSw41Qi4C/JWVm89rdj2WqScDHYyAdwyyppWU4T5c9Fmw== example@example.com"', + ], + [ + 'api:environments:file-copy', + 'post', + '12-d314739e-296f-11e9-b210-d663bd873d93 --source="14-0c7e79ab-1c4a-424e-8446-76ae8be7e851"', + ], ]; } @@ -432,8 +495,9 @@ public function testApiCommandDefinitionRequestBody(string $commandName, string $resource = $this->getResourceFromSpec($this->command->getPath(), $method); foreach ($resource['requestBody']['content']['application/hal+json']['example'] as $propKey => $value) { $this->assertTrue( - $this->command->getDefinition()->hasArgument($propKey) || $this->command->getDefinition() - ->hasOption($propKey), + $this->command->getDefinition() + ->hasArgument($propKey) || $this->command->getDefinition() + ->hasOption($propKey), "Command {$this->command->getName()} does not have expected argument or option $propKey" ); } @@ -442,9 +506,12 @@ public function testApiCommandDefinitionRequestBody(string $commandName, string public function testGetApplicationUuidFromBltYml(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $mockBody = $this->getMockResponseFromSpec('/applications/{applicationUuid}', 'get', '200'); - $this->clientProphecy->request('get', '/applications/' . $mockBody->uuid)->willReturn($mockBody)->shouldBeCalled(); + $this->clientProphecy->request('get', '/applications/' . $mockBody->uuid) + ->willReturn($mockBody) + ->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:applications:find'); $bltConfigFilePath = Path::join($this->projectDir, 'blt', 'blt.yml'); $this->fs->dumpFile($bltConfigFilePath, Yaml::dump(['cloud' => ['appId' => $mockBody->uuid]])); @@ -459,8 +526,12 @@ public function testOrganizationMemberDeleteByUserUuid(): void $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; $memberUuid = '26c4af83-545b-45cb-b165-d537adc9e0b4'; - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); - $this->mockRequest('postOrganizationMemberDelete', [$orgId, $memberUuid], null, 'Member removed'); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); + $this->mockRequest('postOrganizationMemberDelete', [ + $orgId, + $memberUuid, + ], null, 'Member removed'); $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->executeCommand( @@ -480,15 +551,19 @@ public function testOrganizationMemberDeleteByUserUuid(): void */ public function testOrganizationMemberDeleteByUserEmail(): void { - $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2'])->shouldBeCalled(); + $this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']) + ->shouldBeCalled(); $membersResponse = $this->getMockResponseFromSpec('/organizations/{organizationUuid}/members', 'get', 200); $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; $memberMail = $membersResponse->_embedded->items[0]->mail; $memberUuid = $membersResponse->_embedded->items[0]->uuid; $this->clientProphecy->request('get', '/organizations/' . $orgId . '/members') - ->willReturn($membersResponse->_embedded->items)->shouldBeCalled(); + ->willReturn($membersResponse->_embedded->items)->shouldBeCalled(); - $this->mockRequest('postOrganizationMemberDelete', [$orgId, $memberUuid], null, 'Member removed'); + $this->mockRequest('postOrganizationMemberDelete', [ + $orgId, + $memberUuid, + ], null, 'Member removed'); $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->executeCommand( @@ -512,9 +587,12 @@ public function testOrganizationMemberDeleteInvalidEmail(): void $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; $memberUuid = $membersResponse->_embedded->items[0]->mail . 'INVALID'; $this->clientProphecy->request('get', '/organizations/' . $orgId . '/members') - ->willReturn($membersResponse->_embedded->items)->shouldBeCalled(); + ->willReturn($membersResponse->_embedded->items)->shouldBeCalled(); - $this->mockRequest('postOrganizationMemberDelete', [$orgId, $memberUuid], null, 'Member removed'); + $this->mockRequest('postOrganizationMemberDelete', [ + $orgId, + $memberUuid, + ], null, 'Member removed'); $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->expectException(AcquiaCliException::class); @@ -536,7 +614,7 @@ public function testOrganizationMemberDeleteNoMembers(): void $orgId = 'bfafd31a-83a6-4257-b0ec-afdeff83117a'; $memberUuid = $membersResponse->_embedded->items[0]->mail; $this->clientProphecy->request('get', '/organizations/' . $orgId . '/members') - ->willReturn([])->shouldBeCalled(); + ->willReturn([])->shouldBeCalled(); $this->command = $this->getApiCommandByName('api:organizations:member-delete'); $this->expectException(AcquiaCliException::class); diff --git a/tests/phpunit/src/Commands/App/AppOpenCommandTest.php b/tests/phpunit/src/Commands/App/AppOpenCommandTest.php index 67a01ff14..fd77fc9b6 100644 --- a/tests/phpunit/src/Commands/App/AppOpenCommandTest.php +++ b/tests/phpunit/src/Commands/App/AppOpenCommandTest.php @@ -23,7 +23,8 @@ public function testAppOpenCommand(): void { $applicationUuid = 'a47ac10b-58cc-4372-a567-0e02b2c3d470'; $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->startBrowser('https://cloud.acquia.com/a/applications/' . $applicationUuid)->shouldBeCalled(); + $localMachineHelper->startBrowser('https://cloud.acquia.com/a/applications/' . $applicationUuid) + ->shouldBeCalled(); $localMachineHelper->isBrowserAvailable()->willReturn(true); $this->mockRequest('getApplicationByUuid', $applicationUuid); $this->executeCommand(['applicationUuid' => $applicationUuid]); diff --git a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php index e057fc58e..304f1f17d 100644 --- a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php +++ b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php @@ -31,8 +31,8 @@ public function testNoEnvAvailableCommand(): void 'get', "/applications/$application->uuid/environments" ) - ->willReturn([]) - ->shouldBeCalled(); + ->willReturn([]) + ->shouldBeCalled(); $this->mockRequest('getCodeByApplicationUuid', $application->uuid); $this->expectException(AcquiaCliException::class); @@ -58,8 +58,8 @@ public function testNoVcsAvailableCommand(): void 'get', "/applications/{$applications[0]->uuid}/code" ) - ->willReturn([]) - ->shouldBeCalled(); + ->willReturn([]) + ->shouldBeCalled(); $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('No branch or tag is available with this application.'); @@ -120,8 +120,8 @@ public function testNoDeployedVcs(): void 'get', "/applications/{$application->uuid}/environments" ) - ->willReturn($environments) - ->shouldBeCalled(); + ->willReturn($environments) + ->shouldBeCalled(); $this->mockRequest('getCodeByApplicationUuid', $application->uuid); $this->expectException(AcquiaCliException::class); diff --git a/tests/phpunit/src/Commands/App/From/ConfigurationTest.php b/tests/phpunit/src/Commands/App/From/ConfigurationTest.php index 128b6ca55..651ccb42e 100644 --- a/tests/phpunit/src/Commands/App/From/ConfigurationTest.php +++ b/tests/phpunit/src/Commands/App/From/ConfigurationTest.php @@ -37,8 +37,14 @@ public function test(string $configuration, Exception $expected_exception): void public function getTestConfigurations(): array { return [ - 'bad JSON in configuration file' => ['{,}', new JsonException('Syntax error', JSON_ERROR_SYNTAX)], - 'empty configuration file' => [json_encode((object) []), new DomainException('Missing required key: rootPackageDefinition')], + 'bad JSON in configuration file' => [ + '{,}', + new JsonException('Syntax error', JSON_ERROR_SYNTAX), + ], + 'empty configuration file' => [ + json_encode((object) []), + new DomainException('Missing required key: rootPackageDefinition'), + ], ]; } } diff --git a/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php b/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php index 36e09b5ac..ca5d81670 100755 --- a/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php +++ b/tests/phpunit/src/Commands/App/From/DefinedRecommendationTest.php @@ -58,11 +58,19 @@ public function getTestConfigurations(): array new NoRecommendation(), ], 'key value does not match schema' => [ - ['package' => 42, 'constraint' => '', 'replaces' => ['name' => '']], + [ + 'package' => 42, + 'constraint' => '', + 'replaces' => ['name' => ''], + ], new NoRecommendation(), ], 'nested key value does not match schema' => [ - ['package' => '', 'constraint' => '', 'replaces' => ['name' => 42]], + [ + 'package' => '', + 'constraint' => '', + 'replaces' => ['name' => 42], + ], new NoRecommendation(), ], 'invalid patches key' => [ diff --git a/tests/phpunit/src/Commands/App/From/RecommendationsTest.php b/tests/phpunit/src/Commands/App/From/RecommendationsTest.php index e60d65c5a..0932636da 100644 --- a/tests/phpunit/src/Commands/App/From/RecommendationsTest.php +++ b/tests/phpunit/src/Commands/App/From/RecommendationsTest.php @@ -20,7 +20,8 @@ class RecommendationsTest extends TestCase * @param string $configuration * A JSON string from which to create a configuration object. * @param \Acquia\Cli\Command\App\From\Recommendation\RecommendationInterface|\JsonException $expectation - * An expected recommendation or a JSON exception in the case that the given + * An expected recommendation or a JSON exception in the case that the + * given * $configuration is malformed. * @dataProvider getTestConfigurations */ diff --git a/tests/phpunit/src/Commands/App/LinkCommandTest.php b/tests/phpunit/src/Commands/App/LinkCommandTest.php index 83ecfb901..e51cb2e2a 100644 --- a/tests/phpunit/src/Commands/App/LinkCommandTest.php +++ b/tests/phpunit/src/Commands/App/LinkCommandTest.php @@ -25,9 +25,9 @@ public function testLinkCommand(): void $this->mockApplicationRequest(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application. + // Select a Cloud Platform application. 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/App/LogTailCommandTest.php b/tests/phpunit/src/Commands/App/LogTailCommandTest.php index dd9b3fd60..0469243e5 100644 --- a/tests/phpunit/src/Commands/App/LogTailCommandTest.php +++ b/tests/phpunit/src/Commands/App/LogTailCommandTest.php @@ -57,21 +57,23 @@ protected function createCommand(): CommandBase public function testLogTailCommand(?int $stream): void { $this->logStreamManagerProphecy->setColourise(true)->shouldBeCalled(); - $this->logStreamManagerProphecy->setParams(Argument::type('object'))->shouldBeCalled(); - $this->logStreamManagerProphecy->setLogTypeFilter(["bal-request"])->shouldBeCalled(); + $this->logStreamManagerProphecy->setParams(Argument::type('object')) + ->shouldBeCalled(); + $this->logStreamManagerProphecy->setLogTypeFilter(["bal-request"]) + ->shouldBeCalled(); $this->logStreamManagerProphecy->stream()->shouldBeCalled(); $this->mockGetEnvironment(); $this->mockLogStreamRequest(); $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select environment. + // Select environment. 0, - // Select log. + // Select log. $stream, ]); @@ -113,15 +115,15 @@ public function testLogTailNode(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('No compatible environments found'); $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select environment. + // Select environment. 0, - // Select log. + // Select log. 0, ]); } @@ -137,7 +139,7 @@ private function mockLogStreamRequest(): void 'get', '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/logstream' ) - ->willReturn($response) - ->shouldBeCalled(); + ->willReturn($response) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/App/NewCommandTest.php b/tests/phpunit/src/Commands/App/NewCommandTest.php index fe3499925..a4196ebb5 100644 --- a/tests/phpunit/src/Commands/App/NewCommandTest.php +++ b/tests/phpunit/src/Commands/App/NewCommandTest.php @@ -36,7 +36,12 @@ public function provideTestNewDrupalCommand(): array { return [ [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project']], - [['acquia_drupal_recommended' => 'acquia/drupal-recommended-project', 'test-dir']], + [ + [ + 'acquia_drupal_recommended' => 'acquia/drupal-recommended-project', + 'test-dir', + ], + ], ]; } @@ -67,15 +72,17 @@ public function testNewDrupalCommand(array $package, string $directory = 'drupal $localMachineHelper = $this->mockLocalMachineHelper(); $mockFileSystem = $this->mockGetFilesystem($localMachineHelper); - $localMachineHelper->checkRequiredBinariesExist(["composer"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["composer"]) + ->shouldBeCalled(); $this->mockExecuteComposerCreate($this->newProjectDir, $localMachineHelper, $process, $project); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $this->mockExecuteGitInit($localMachineHelper, $this->newProjectDir, $process); $this->mockExecuteGitAdd($localMachineHelper, $this->newProjectDir, $process); $this->mockExecuteGitCommit($localMachineHelper, $this->newProjectDir, $process); $inputs = [ - // Choose a starting project. + // Choose a starting project. $project, ]; $this->executeCommand([ @@ -107,15 +114,17 @@ public function testNewNextJSAppCommand(array $package, string $directory = 'nex $mockFileSystem = $this->mockGetFilesystem($localMachineHelper); - $localMachineHelper->checkRequiredBinariesExist(["node"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["node"]) + ->shouldBeCalled(); $this->mockExecuteNpxCreate($this->newProjectDir, $localMachineHelper, $process); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $this->mockExecuteGitInit($localMachineHelper, $this->newProjectDir, $process); $this->mockExecuteGitAdd($localMachineHelper, $this->newProjectDir, $process); $this->mockExecuteGitCommit($localMachineHelper, $this->newProjectDir, $process); $inputs = [ - // Choose a starting project. + // Choose a starting project. $project, ]; $this->executeCommand([ @@ -144,9 +153,9 @@ protected function mockExecuteComposerCreate( '--no-interaction', ]; $localMachineHelper - ->execute($command) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteNpxCreate( @@ -162,9 +171,9 @@ protected function mockExecuteNpxCreate( $projectDir, ]; $localMachineHelper - ->execute($command) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitInit( @@ -178,9 +187,9 @@ protected function mockExecuteGitInit( '--initial-branch=main', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitAdd( @@ -194,9 +203,9 @@ protected function mockExecuteGitAdd( '-A', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitCommit( @@ -212,8 +221,8 @@ protected function mockExecuteGitCommit( '--quiet', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php index 0b6385441..be77734c1 100644 --- a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php +++ b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php @@ -62,14 +62,16 @@ protected function assertValidDateFormat(string $date, string $format): void /** * Test the app:new:from:drupal7 command. * - * Since this command inspects an actual Drupal site to determine its enabled - * modules, the inspector must be mocked. A set of Drupal 7 extensions is - * given by the extensions file. This project provides a shell script to help - * generate that file from an existing Drupal 7 site. An example shell command - * is given below. + * Since this command inspects an actual Drupal site to determine its + * enabled modules, the inspector must be mocked. A set of Drupal 7 + * extensions is given by the extensions file. This project provides a + * shell script to help generate that file from an existing Drupal 7 site. + * An example shell command is given below. * * @code - * drush pm:list --pipe --format=json | /path/to/this/project/tests/fixtures/drupal7/drush_to_extensions_test_file_format.sh > extensions.json + * drush pm:list --pipe --format=json | + * /path/to/this/project/tests/fixtures/drupal7/drush_to_extensions_test_file_format.sh + * > extensions.json * @endcode * @param string $extensions_file * An extensions file. See above. @@ -100,9 +102,11 @@ public function testNewFromDrupal7Command(string $extensions_json, string $recom $localMachineHelper = $this->mockLocalMachineHelper(); $mockFileSystem = $this->mockGetFilesystem($localMachineHelper); - $localMachineHelper->checkRequiredBinariesExist(["composer"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["composer"]) + ->shouldBeCalled(); $this->mockExecuteComposerCreate($race_condition_proof_tmpdir, $localMachineHelper, $process); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $this->mockExecuteGitInit($localMachineHelper, $race_condition_proof_tmpdir, $process); $this->mockExecuteGitAdd($localMachineHelper, $race_condition_proof_tmpdir, $process); $this->mockExecuteGitCommit($localMachineHelper, $race_condition_proof_tmpdir, $process); @@ -145,9 +149,9 @@ protected function mockExecuteComposerCreate( '--no-interaction', ]; $localMachineHelper - ->execute($command) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitInit( @@ -162,9 +166,9 @@ protected function mockExecuteGitInit( '--quiet', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitAdd( @@ -178,9 +182,9 @@ protected function mockExecuteGitAdd( '-A', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteGitCommit( @@ -196,8 +200,8 @@ protected function mockExecuteGitCommit( '--quiet', ]; $localMachineHelper - ->execute($command, null, $projectDir) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, null, $projectDir) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php index 373342fca..5308821e1 100644 --- a/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php +++ b/tests/phpunit/src/Commands/Archive/ArchiveExporterCommandTest.php @@ -25,7 +25,12 @@ protected function createCommand(): CommandBase public function setUp(): void { - self::unsetEnvVars(['ACLI_DB_HOST', 'ACLI_DB_USER', 'ACLI_DB_PASSWORD', 'ACLI_DB_NAME']); + self::unsetEnvVars([ + 'ACLI_DB_HOST', + 'ACLI_DB_USER', + 'ACLI_DB_PASSWORD', + 'ACLI_DB_NAME', + ]); parent::setUp(); } @@ -35,19 +40,24 @@ public function testArchiveExport(): void $destinationDir = 'foo'; $localMachineHelper = $this->mockLocalMachineHelper(); $fileSystem = $this->mockFileSystem($destinationDir); - $localMachineHelper->getFilesystem()->willReturn($fileSystem->reveal())->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($fileSystem->reveal()) + ->shouldBeCalled(); $this->mockExecutePvExists($localMachineHelper); $this->mockExecuteDrushExists($localMachineHelper); $this->mockExecuteDrushStatus($localMachineHelper, $this->projectDir); $this->mockCreateMySqlDumpOnLocal($localMachineHelper); - $localMachineHelper->checkRequiredBinariesExist(["tar"])->shouldBeCalled(); - $localMachineHelper->execute(Argument::type('array'), Argument::type('callable'), null, true)->willReturn($this->mockProcess())->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["tar"]) + ->shouldBeCalled(); + $localMachineHelper->execute(Argument::type('array'), Argument::type('callable'), null, true) + ->willReturn($this->mockProcess()) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); $inputs = [ - // ... Do you want to continue? (yes/no) [yes] + // ... Do you want to continue? (yes/no) [yes] 'y', ]; $this->executeCommand([ @@ -70,9 +80,11 @@ protected function mockFileSystem(string $destinationDir): ObjectProphecy ['override' => true, 'delete' => true], Argument::type(Finder::class) )->shouldBeCalled(); - $fileSystem->exists($destinationDir)->willReturn(true)->shouldBeCalled(); + $fileSystem->exists($destinationDir) + ->willReturn(true) + ->shouldBeCalled(); $fileSystem->rename(Argument::type('string'), Argument::type('string')) - ->shouldBeCalled(); + ->shouldBeCalled(); $fileSystem->remove(Argument::type('string'))->shouldBeCalled(); $fileSystem->mkdir(Argument::type('array'))->shouldBeCalled(); return $fileSystem; diff --git a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php index 0a1c9c2a7..4f5a868f9 100644 --- a/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php +++ b/tests/phpunit/src/Commands/Auth/AuthLoginCommandTest.php @@ -28,13 +28,18 @@ protected function createCommand(): CommandBase public function testAuthLoginCommand(): void { $this->mockRequest('getAccount'); - $this->clientServiceProphecy->setConnector(Argument::type(Connector::class))->shouldBeCalled(); - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->setConnector(Argument::type(Connector::class)) + ->shouldBeCalled(); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); $this->createDataStores(); $this->command = $this->createCommand(); - $this->executeCommand(['--key' => $this->key, '--secret' => $this->secret]); + $this->executeCommand([ + '--key' => $this->key, + '--secret' => $this->secret, + ]); $output = $this->getDisplay(); $this->assertStringContainsString('Saved credentials', $output); @@ -44,14 +49,19 @@ public function testAuthLoginCommand(): void public function testAuthLoginNoKeysCommand(): void { $this->mockRequest('getAccount'); - $this->clientServiceProphecy->setConnector(Argument::type(Connector::class))->shouldBeCalled(); - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->setConnector(Argument::type(Connector::class)) + ->shouldBeCalled(); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); $this->fs->dumpFile($this->cloudConfigFilepath, json_encode(['send_telemetry' => false])); $this->createDataStores(); $this->command = $this->createCommand(); - $this->executeCommand(['--key' => $this->key, '--secret' => $this->secret]); + $this->executeCommand([ + '--key' => $this->key, + '--secret' => $this->secret, + ]); $output = $this->getDisplay(); $this->assertStringContainsString('Saved credentials', $output); @@ -63,12 +73,12 @@ public function providerTestAuthLoginInvalidInputCommand(): Generator yield [ [], - ['--key' => 'no spaces are allowed' , '--secret' => $this->secret], + ['--key' => 'no spaces are allowed', '--secret' => $this->secret], ]; yield [ [], - ['--key' => 'shorty' , '--secret' => $this->secret], + ['--key' => 'shorty', '--secret' => $this->secret], ]; yield [ @@ -82,7 +92,8 @@ public function providerTestAuthLoginInvalidInputCommand(): Generator */ public function testAuthLoginInvalidInputCommand(array $inputs, array $args): void { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); $this->createDataStores(); $this->command = $this->createCommand(); @@ -92,7 +103,8 @@ public function testAuthLoginInvalidInputCommand(array $inputs, array $args): vo public function testAuthLoginInvalidDatastore(): void { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); $data = [ 'acli_key' => 'key2', diff --git a/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php b/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php index 309330607..a915c6a4c 100644 --- a/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php +++ b/tests/phpunit/src/Commands/Auth/AuthLogoutCommandTest.php @@ -31,7 +31,8 @@ public function testAuthLogoutCommand(): void public function testAuthLogoutInvalidDatastore(): void { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockCloudConfigFile(); $data = [ 'acli_key' => 'key2', diff --git a/tests/phpunit/src/Commands/ChecklistTest.php b/tests/phpunit/src/Commands/ChecklistTest.php index aa2e1fdba..50cc65701 100644 --- a/tests/phpunit/src/Commands/ChecklistTest.php +++ b/tests/phpunit/src/Commands/ChecklistTest.php @@ -33,7 +33,10 @@ public function testSpinner(): void $outputCallback = static function (string $type, string $buffer) use ($checklist): void { $checklist->updateProgressBar($buffer); }; - $this->localMachineHelper->execute(['echo', 'hello world'], $outputCallback, null, false); + $this->localMachineHelper->execute([ + 'echo', + 'hello world', + ], $outputCallback, null, false); // Complete the item. $checklist->completePreviousItem(); diff --git a/tests/phpunit/src/Commands/ClearCacheCommandTest.php b/tests/phpunit/src/Commands/ClearCacheCommandTest.php index f972c8ae9..3124de0b3 100644 --- a/tests/phpunit/src/Commands/ClearCacheCommandTest.php +++ b/tests/phpunit/src/Commands/ClearCacheCommandTest.php @@ -35,11 +35,12 @@ public function testAliasesAreCached(): void ); $applicationsResponse = $this->filterApplicationsResponse($applicationsResponse, 1, true); $this->clientProphecy->request('get', '/applications') - ->willReturn($applicationsResponse->{'_embedded'}->items) - // Ensure this is only called once, even though we execute the command twice. - ->shouldBeCalledTimes(1); + ->willReturn($applicationsResponse->{'_embedded'}->items) + // Ensure this is only called once, even though we execute the command twice. + ->shouldBeCalledTimes(1); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->mockApplicationRequest(); $this->mockRequest('getApplicationIdes', 'a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->mockRequest('getAccount'); @@ -47,7 +48,7 @@ public function testAliasesAreCached(): void $alias = 'devcloud2'; $args = ['applicationUuid' => $alias]; $inputs = [ - // Would you like to link the Cloud application Sample application to this repository? + // Would you like to link the Cloud application Sample application to this repository? 'n', ]; diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php index 6b825fe33..c1ae1e1f7 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPhpVersionCommandTest.php @@ -18,8 +18,11 @@ class CodeStudioPhpVersionCommandTest extends CommandTestBase { private string $gitLabHost = 'gitlabhost'; + private string $gitLabToken = 'gitlabtoken'; + private int $gitLabProjectId = 33; + public static string $applicationUuid = 'a47ac10b-58cc-4372-a567-0e02b2c3d470'; protected function createCommand(): CommandBase @@ -98,9 +101,10 @@ public function testPhpVersionAddFail(): void [$mockedProject], ); - $projects->variables($this->gitLabProjectId)->willReturn($this->getMockGitLabVariables()); + $projects->variables($this->gitLabProjectId) + ->willReturn($this->getMockGitLabVariables()); $projects->addVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string')) - ->willThrow(RuntimeException::class); + ->willThrow(RuntimeException::class); $gitlabClient->projects()->willReturn($projects); $this->command->setGitLabClient($gitlabClient->reveal()); @@ -131,7 +135,8 @@ public function testPhpVersionAdd(): void [$mockedProject], ); - $projects->variables($this->gitLabProjectId)->willReturn($this->getMockGitLabVariables()); + $projects->variables($this->gitLabProjectId) + ->willReturn($this->getMockGitLabVariables()); $projects->addVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string')); $gitlabClient->projects()->willReturn($projects); @@ -175,7 +180,7 @@ public function testPhpVersionUpdateFail(): void ]; $projects->variables($this->gitLabProjectId)->willReturn($variables); $projects->updateVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string')) - ->willThrow(RuntimeException::class); + ->willThrow(RuntimeException::class); $gitlabClient->projects()->willReturn($projects); $this->command->setGitLabClient($gitlabClient->reveal()); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php index e37f022a1..6f37b8540 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioPipelinesMigrateCommandTest.php @@ -16,7 +16,8 @@ use Symfony\Component\Yaml\Yaml; /** - * @property \Acquia\Cli\Command\CodeStudio\CodeStudioPipelinesMigrateCommand $command + * @property \Acquia\Cli\Command\CodeStudio\CodeStudioPipelinesMigrateCommand + * $command * @requires OS linux|darwin */ class CodeStudioPipelinesMigrateCommandTest extends CommandTestBase @@ -24,9 +25,13 @@ class CodeStudioPipelinesMigrateCommandTest extends CommandTestBase use IdeRequiredTestTrait; private string $gitLabHost = 'gitlabhost'; + private string $gitLabToken = 'gitlabtoken'; + private int $gitLabProjectId = 33; + private int $gitLabTokenId = 118; + public static string $applicationUuid = 'a47ac10b-58cc-4372-a567-0e02b2c3d470'; public function setUp(): void @@ -54,15 +59,15 @@ public function providerTestCommand(): array { return [ [ - // One project. + // One project. [$this->getMockedGitLabProject($this->gitLabProjectId)], - // Inputs. + // Inputs. [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // @todo + // @todo '0', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. @@ -140,10 +145,13 @@ public function testCommand(mixed $mockedGitlabProjects, mixed $inputs, mixed $a 'variable_type' => 'env_var', ], ]; - $projects->variables($this->gitLabProjectId)->willReturn($gitlabCicdVariables); + $projects->variables($this->gitLabProjectId) + ->willReturn($gitlabCicdVariables); $projects->update($this->gitLabProjectId, Argument::type('array')); $gitlabClient->projects()->willReturn($projects); - $localMachineHelper->getFilesystem()->willReturn(new Filesystem())->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn(new Filesystem()) + ->shouldBeCalled(); $this->command->setGitLabClient($gitlabClient->reveal()); $this->mockRequest('getApplications'); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index 52265c6e5..a2d4b6993 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -29,9 +29,11 @@ class CodeStudioWizardCommandTest extends WizardTestBase use IdeRequiredTestTrait; private string $gitLabHost = 'gitlabhost'; + private string $gitLabToken = 'gitlabtoken'; private int $gitLabProjectId = 33; + private int $gitLabTokenId = 118; public function setUp(): void @@ -59,13 +61,13 @@ public function providerTestCommand(): array { return [ [ - // One project. + // One project. [$this->getMockedGitLabProject($this->gitLabProjectId)], - // Inputs. + // Inputs. [ - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -76,14 +78,17 @@ public function providerTestCommand(): array ], // Two projects. [ - [$this->getMockedGitLabProject($this->gitLabProjectId), $this->getMockedGitLabProject($this->gitLabProjectId)], - // Inputs. [ - // Found multiple projects that could match the Sample application 1 application. Choose which one to configure. + $this->getMockedGitLabProject($this->gitLabProjectId), + $this->getMockedGitLabProject($this->gitLabProjectId), + ], + // Inputs. + [ + // Found multiple projects that could match the Sample application 1 application. Choose which one to configure. '0', - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -93,19 +98,19 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Select a project type Drupal_project. + // Select a project type Drupal_project. '0', - // Select PHP version 8.1. + // Select PHP version 8.1. '0', - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -115,19 +120,19 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Select a project type Drupal_project. + // Select a project type Drupal_project. '0', - // Select PHP version 8.2. + // Select PHP version 8.2. '1', - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -137,19 +142,19 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Select a project type Node_project. + // Select a project type Node_project. '1', - // Select NODE version 18.17.1. + // Select NODE version 18.17.1. '0', - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -159,19 +164,19 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Select a project type Node_project. + // Select a project type Node_project. '1', - // Select NODE version 20.5.1. + // Select NODE version 20.5.1. '1', - // Do you want to continue? + // Do you want to continue? 'y', - // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: 'y', ], // Args. @@ -181,15 +186,15 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'n', - // Choose project. + // Choose project. '0', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. @@ -199,84 +204,84 @@ public function providerTestCommand(): array ], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Enter Cloud Key. + // Enter Cloud Key. $this->key, - // Enter Cloud secret,. + // Enter Cloud secret,. $this->secret, - // Select a project type Drupal_project. + // Select a project type Drupal_project. '0', - // Select PHP version 8.1. + // Select PHP version 8.1. '0', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. [], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Enter Cloud Key. + // Enter Cloud Key. $this->key, - // Enter Cloud secret,. + // Enter Cloud secret,. $this->secret, - // Select a project type Node_project. + // Select a project type Node_project. '1', - // Select NODE version 18.17.1. + // Select NODE version 18.17.1. '0', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. [], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Enter Cloud Key. + // Enter Cloud Key. $this->key, - // Enter Cloud secret,. + // Enter Cloud secret,. $this->secret, - // Select a project type Drupal_project. + // Select a project type Drupal_project. '0', - // Select PHP version 8.2. + // Select PHP version 8.2. '1', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. [], ], [ - // No projects. + // No projects. [], - // Inputs. + // Inputs. [ - // 'Would you like to create a new Code Studio project? + // 'Would you like to create a new Code Studio project? 'y', - // Enter Cloud Key. + // Enter Cloud Key. $this->key, - // Enter Cloud secret,. + // Enter Cloud secret,. $this->secret, - // Select a project type Node_project. + // Select a project type Node_project. '1', - // Select NODE version 20.5.1. + // Select NODE version 20.5.1. '1', - // Do you want to continue? + // Do you want to continue? 'y', ], // Args. @@ -290,7 +295,8 @@ public function providerTestCommand(): array */ public function testCommand(array $mockedGitlabProjects, array $inputs, array $args): void { - $this->clientServiceProphecy->setConnector(Argument::type(Connector::class))->shouldBeCalled(); + $this->clientServiceProphecy->setConnector(Argument::type(Connector::class)) + ->shouldBeCalled(); $this->mockRequest('getAccount'); $this->mockGitLabPermissionsRequest($this::$applicationUuid); @@ -308,7 +314,8 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a 'namespace_id' => 47, 'topics' => 'Acquia Cloud Application', ]; - $projects->create('Sample-application-1', $parameters)->willReturn($this->getMockedGitLabProject($this->gitLabProjectId)); + $projects->create('Sample-application-1', $parameters) + ->willReturn($this->getMockedGitLabProject($this->gitLabProjectId)); $this->mockGitLabProjectsTokens($projects); $parameters = [ 'container_registry_access_level' => 'disabled', @@ -317,7 +324,8 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a 'initialize_with_readme' => true, 'topics' => 'Acquia Cloud Application', ]; - $projects->update($this->gitLabProjectId, $parameters)->shouldBeCalled(); + $projects->update($this->gitLabProjectId, $parameters) + ->shouldBeCalled(); $projects->uploadAvatar( 33, Argument::type('string'), @@ -328,18 +336,20 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a $parameters = [ 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', ]; - $projects->update($this->gitLabProjectId, $parameters)->shouldBeCalled(); + $projects->update($this->gitLabProjectId, $parameters) + ->shouldBeCalled(); } else { $schedules = $this->prophet->prophesize(Schedules::class); $schedules->showAll($this->gitLabProjectId)->willReturn([]); $pipeline = ['id' => 1]; $parameters = [ - // Every Thursday at midnight. + // Every Thursday at midnight. 'cron' => '0 0 * * 4', 'description' => 'Code Studio Automatic Updates', 'ref' => 'master', ]; - $schedules->create($this->gitLabProjectId, $parameters)->willReturn($pipeline); + $schedules->create($this->gitLabProjectId, $parameters) + ->willReturn($pipeline); $schedules->addVariable($this->gitLabProjectId, $pipeline['id'], [ 'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE', 'value' => 'true', @@ -359,8 +369,10 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a $localMachineHelper->checkRequiredBinariesExist(['git']); $this->mockExecuteGlabExists($localMachineHelper); $process = $this->mockProcess(); - $localMachineHelper->execute(Argument::containing('remote'), Argument::type('callable'), '/home/ide/project', false)->willReturn($process->reveal()); - $localMachineHelper->execute(Argument::containing('push'), Argument::type('callable'), '/home/ide/project', false)->willReturn($process->reveal()); + $localMachineHelper->execute(Argument::containing('remote'), Argument::type('callable'), '/home/ide/project', false) + ->willReturn($process->reveal()); + $localMachineHelper->execute(Argument::containing('push'), Argument::type('callable'), '/home/ide/project', false) + ->willReturn($process->reveal()); $this->mockGetCurrentBranchName($localMachineHelper); $this->mockGitlabGetHost($localMachineHelper, $this->gitLabHost); @@ -434,11 +446,15 @@ protected function mockGitLabProjectsTokens(ObjectProphecy $projects): void 'user_id' => 154, ], ]; - $projects->projectAccessTokens($this->gitLabProjectId)->willReturn($tokens)->shouldBeCalled(); - $projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId)->shouldBeCalled(); + $projects->projectAccessTokens($this->gitLabProjectId) + ->willReturn($tokens) + ->shouldBeCalled(); + $projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId) + ->shouldBeCalled(); $token = $tokens[0]; $token['token'] = 'token'; - $projects->createProjectAccessToken($this->gitLabProjectId, Argument::type('array'))->willReturn($token); + $projects->createProjectAccessToken($this->gitLabProjectId, Argument::type('array')) + ->willReturn($token); } protected function mockGetCurrentBranchName(mixed $localMachineHelper): void @@ -542,10 +558,16 @@ protected function mockGitLabVariables(int $gitlabProjectId, ObjectProphecy $pro $variables = $this->getMockGitLabVariables(); $projects->variables($gitlabProjectId)->willReturn($variables); foreach ($variables as $variable) { - $projects->addVariable($gitlabProjectId, Argument::type('string'), Argument::type('string'), Argument::type('bool'), null, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']])->shouldBeCalled(); + $projects->addVariable($gitlabProjectId, Argument::type('string'), Argument::type('string'), Argument::type('bool'), null, [ + 'masked' => $variable['masked'], + 'variable_type' => $variable['variable_type'], + ])->shouldBeCalled(); } foreach ($variables as $variable) { - $projects->updateVariable($this->gitLabProjectId, $variable['key'], $variable['value'], false, null, ['masked' => true, 'variable_type' => 'env_var'])->shouldBeCalled(); + $projects->updateVariable($this->gitLabProjectId, $variable['key'], $variable['value'], false, null, [ + 'masked' => true, + 'variable_type' => 'env_var', + ])->shouldBeCalled(); } } } diff --git a/tests/phpunit/src/Commands/CommandBaseTest.php b/tests/phpunit/src/Commands/CommandBaseTest.php index 2dfee6b90..6fa9b3201 100644 --- a/tests/phpunit/src/Commands/CommandBaseTest.php +++ b/tests/phpunit/src/Commands/CommandBaseTest.php @@ -26,11 +26,12 @@ protected function createCommand(): CommandBase public function testUnauthenticatedFailure(): void { - $this->clientServiceProphecy->isMachineAuthenticated()->willReturn(false); + $this->clientServiceProphecy->isMachineAuthenticated() + ->willReturn(false); $this->removeMockConfigFiles(); $inputs = [ - // Would you like to share anonymous performance usage and data? + // Would you like to share anonymous performance usage and data? 'n', ]; $this->expectException(AcquiaCliException::class); @@ -74,8 +75,14 @@ public function testCloudAppUuidArg(string $uuid): void public function providerTestInvalidCloudAppUuidArg(): array { return [ - ['a47ac10b-58cc-4372-a567-0e02b2c3d4', 'This value should have exactly 36 characters.'], - ['a47ac10b-58cc-4372-a567-0e02b2c3d47z', 'This is not a valid UUID.'], + [ + 'a47ac10b-58cc-4372-a567-0e02b2c3d4', + 'This value should have exactly 36 characters.', + ], + [ + 'a47ac10b-58cc-4372-a567-0e02b2c3d47z', + 'This is not a valid UUID.', + ], ]; } @@ -95,9 +102,18 @@ public function testInvalidCloudAppUuidArg(string $uuid, string $message): void public function providerTestInvalidCloudEnvironmentAlias(): array { return [ - ['bl.a', 'This value is too short. It should have 5 characters or more.'], - ['blarg', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], - ['12345', 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]'], + [ + 'bl.a', + 'This value is too short. It should have 5 characters or more.', + ], + [ + 'blarg', + 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]', + ], + [ + '12345', + 'You must enter either an environment ID or alias. Environment aliases must match the pattern [app-name].[env]', + ], ]; } diff --git a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php index 8540928e9..8ac115a92 100644 --- a/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php +++ b/tests/phpunit/src/Commands/Email/EmailInfoForSubscriptionCommandTest.php @@ -29,7 +29,7 @@ public function setUp(): void public function testEmailInfoForSubscription(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); @@ -38,7 +38,8 @@ public function testEmailInfoForSubscription(): void // Duplicating the request to ensure there is at least one domain with a successful, pending, and failed health code. $getDomainsResponse2 = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); $totalDomainsList = array_merge($getDomainsResponse->_embedded->items, $getDomainsResponse2->_embedded->items); - $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn($totalDomainsList); + $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains") + ->willReturn($totalDomainsList); $totalDomainsList[2]->domain_name = 'example3.com'; $totalDomainsList[2]->health->code = '200'; @@ -54,7 +55,8 @@ public function testEmailInfoForSubscription(): void // Duplicating the request to ensure added domains are included in association list. $getAppDomainsResponse2 = $this->getMockResponseFromSpec('/applications/{applicationUuid}/email/domains', 'get', '200'); $totalAppDomainsList = array_merge($getAppDomainsResponse->_embedded->items, $getAppDomainsResponse2->_embedded->items); - $this->clientProphecy->request('get', "/applications/{$applicationsResponse->_embedded->items[0]->uuid}/email/domains")->willReturn($totalAppDomainsList); + $this->clientProphecy->request('get', "/applications/{$applicationsResponse->_embedded->items[0]->uuid}/email/domains") + ->willReturn($totalAppDomainsList); $totalAppDomainsList[2]->domain_name = 'example3.com'; $totalAppDomainsList[2]->flags->associated = true; @@ -81,13 +83,14 @@ public function testEmailInfoForSubscription(): void public function testEmailInfoForSubscriptionNoApps(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); - $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn($getDomainsResponse->_embedded->items); + $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains") + ->willReturn($getDomainsResponse->_embedded->items); $this->mockRequest('getApplications'); @@ -99,15 +102,16 @@ public function testEmailInfoForSubscriptionNoApps(): void public function testEmailInfoForSubscriptionWith101Apps(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, - // Do you wish to continue? + // Do you wish to continue? 'no', ]; $subscriptions = $this->mockRequest('getSubscriptions'); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); - $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn($getDomainsResponse->_embedded->items); + $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains") + ->willReturn($getDomainsResponse->_embedded->items); $applicationsResponse = $this->getMockResponseFromSpec('/applications', 'get', '200'); $applicationsResponse->_embedded->items[0]->subscription->uuid = $subscriptions[0]->uuid; @@ -119,10 +123,12 @@ public function testEmailInfoForSubscriptionWith101Apps(): void $applicationsResponse->_embedded->items[$i]->subscription->uuid = $subscriptions[0]->uuid; } - $this->clientProphecy->request('get', '/applications')->willReturn($applicationsResponse->_embedded->items); + $this->clientProphecy->request('get', '/applications') + ->willReturn($applicationsResponse->_embedded->items); foreach ($applicationsResponse->_embedded->items as $app) { - $this->clientProphecy->request('get', "/applications/{$app->uuid}/email/domains")->willReturn([]); + $this->clientProphecy->request('get', "/applications/{$app->uuid}/email/domains") + ->willReturn([]); } $this->executeCommand([], $inputs); @@ -133,12 +139,13 @@ public function testEmailInfoForSubscriptionWith101Apps(): void public function testEmailInfoForSubscriptionNoDomains(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); - $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn([]); + $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains") + ->willReturn([]); $this->executeCommand([], $inputs); $output = $this->getDisplay(); @@ -148,19 +155,21 @@ public function testEmailInfoForSubscriptionNoDomains(): void public function testEmailInfoForSubscriptionNoAppDomains(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, ]; $subscriptions = $this->mockRequest('getSubscriptions'); $getDomainsResponse = $this->getMockResponseFromSpec('/subscriptions/{subscriptionUuid}/domains', 'get', '200'); - $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains")->willReturn($getDomainsResponse->_embedded->items); + $this->clientProphecy->request('get', "/subscriptions/{$subscriptions[0]->uuid}/domains") + ->willReturn($getDomainsResponse->_embedded->items); $applicationsResponse = $this->mockApplicationsRequest(); $applicationsResponse->_embedded->items[0]->subscription->uuid = $subscriptions[0]->uuid; - $this->clientProphecy->request('get', "/applications/{$applicationsResponse->_embedded->items[0]->uuid}/email/domains")->willReturn([]); + $this->clientProphecy->request('get', "/applications/{$applicationsResponse->_embedded->items[0]->uuid}/email/domains") + ->willReturn([]); $this->executeCommand([], $inputs); $output = $this->getDisplay(); @@ -170,12 +179,12 @@ public function testEmailInfoForSubscriptionNoAppDomains(): void public function testEmailInfoForSubscriptionNoSubscriptions(): void { $inputs = [ - // Select a Cloud Platform subscription. + // Select a Cloud Platform subscription. 0, ]; $this->clientProphecy->request('get', '/subscriptions') - ->willReturn([]) - ->shouldBeCalledTimes(1); + ->willReturn([]) + ->shouldBeCalledTimes(1); $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('You have no Cloud subscriptions.'); $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php index 2e644a169..5916748b1 100644 --- a/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCertCreateCommandTest.php @@ -27,8 +27,12 @@ public function testCreateCert(): void $keyName = 'key.pem'; $label = 'My certificate'; $csrId = 123; - $localMachineHelper->readFile($certName)->willReturn($certContents)->shouldBeCalled(); - $localMachineHelper->readFile($keyName)->willReturn($keyContents)->shouldBeCalled(); + $localMachineHelper->readFile($certName) + ->willReturn($certContents) + ->shouldBeCalled(); + $localMachineHelper->readFile($keyName) + ->willReturn($keyContents) + ->shouldBeCalled(); $sslResponse = $this->getMockResponseFromSpec( '/environments/{environmentId}/ssl/certificates', @@ -46,8 +50,8 @@ public function testCreateCert(): void ], ]; $this->clientProphecy->request('post', "/environments/{$environments[1]->id}/ssl/certificates", $options) - ->willReturn($sslResponse->{'Site is being imported'}->value) - ->shouldBeCalled(); + ->willReturn($sslResponse->{'Site is being imported'}->value) + ->shouldBeCalled(); $this->mockNotificationResponseFromObject($sslResponse->{'Site is being imported'}->value); $this->executeCommand( @@ -59,9 +63,9 @@ public function testCreateCert(): void 'private-key' => $keyName, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. + // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. 'n', - // Select a Cloud Platform application: [Sample application 1]: + // Select a Cloud Platform application: [Sample application 1]: 0, 'n', 1, @@ -87,8 +91,12 @@ public function testCreateCertNode(): void $keyName = 'key.pem'; $label = 'My certificate'; $csrId = 123; - $localMachineHelper->readFile($certName)->willReturn($certContents)->shouldBeCalled(); - $localMachineHelper->readFile($keyName)->willReturn($keyContents)->shouldBeCalled(); + $localMachineHelper->readFile($certName) + ->willReturn($certContents) + ->shouldBeCalled(); + $localMachineHelper->readFile($keyName) + ->willReturn($keyContents) + ->shouldBeCalled(); $sslResponse = $this->getMockResponseFromSpec( '/environments/{environmentId}/ssl/certificates', @@ -106,8 +114,8 @@ public function testCreateCertNode(): void ], ]; $this->clientProphecy->request('post', "/environments/{$environments[0]->id}/ssl/certificates", $options) - ->willReturn($sslResponse->{'Site is being imported'}->value) - ->shouldBeCalled(); + ->willReturn($sslResponse->{'Site is being imported'}->value) + ->shouldBeCalled(); $this->mockNotificationResponseFromObject($sslResponse->{'Site is being imported'}->value); $this->executeCommand( @@ -119,9 +127,9 @@ public function testCreateCertNode(): void 'private-key' => $keyName, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. + // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. 'n', - // Select a Cloud Platform application: [Sample application 1]: + // Select a Cloud Platform application: [Sample application 1]: 0, ] ); diff --git a/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php index 4f36f6d06..3c2e9e736 100644 --- a/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCopyCronCommandTest.php @@ -28,8 +28,8 @@ public function testCopyCronTasksCommandTest(): void 'get', '/environments/' . $environmentsResponse->{'_embedded'}->items[0]->id . '/crons' ) - ->willReturn($sourceCronsListResponse->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($sourceCronsListResponse->{'_embedded'}->items) + ->shouldBeCalled(); $createCronResponse = $this->getMockResponseFromSpec('/environments/{environmentId}/crons', 'post', '202'); $this->clientProphecy->request( @@ -37,8 +37,8 @@ public function testCopyCronTasksCommandTest(): void '/environments/' . $environmentsResponse->{'_embedded'}->items[2]->id . '/crons', Argument::type('array') ) - ->willReturn($createCronResponse->{'Adding cron'}->value) - ->shouldBeCalled(); + ->willReturn($createCronResponse->{'Adding cron'}->value) + ->shouldBeCalled(); $source = '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; @@ -80,8 +80,8 @@ public function testNoCronJobOnSource(): void 'get', '/environments/' . $environmentsResponse->{'_embedded'}->items[0]->id . '/crons' ) - ->willReturn([]) - ->shouldBeCalled(); + ->willReturn([]) + ->shouldBeCalled(); $source = '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; @@ -110,8 +110,8 @@ public function testExceptionOnCronJobCopy(): void 'get', '/environments/' . $environmentsResponse->{'_embedded'}->items[0]->id . '/crons' ) - ->willReturn($sourceCronsListResponse->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($sourceCronsListResponse->{'_embedded'}->items) + ->shouldBeCalled(); $this->getMockResponseFromSpec('/environments/{environmentId}/crons', 'post', '202'); $this->clientProphecy->request( @@ -119,7 +119,7 @@ public function testExceptionOnCronJobCopy(): void '/environments/' . $environmentsResponse->{'_embedded'}->items[2]->id . '/crons', Argument::type('array') ) - ->willThrow(Exception::class); + ->willThrow(Exception::class); $source = '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'; $dest = '32-a47ac10b-58cc-4372-a567-0e02b2c3d470'; diff --git a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php index d7fc310f4..3b8b301b9 100644 --- a/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvCreateCommandTest.php @@ -32,24 +32,24 @@ private function setupCdeTest(string $label): string 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn($response1->_embedded->items, $response2->_embedded->items) - ->shouldBeCalled(); + ->willReturn($response1->_embedded->items, $response2->_embedded->items) + ->shouldBeCalled(); $codeResponse = $this->getMockResponseFromSpec("/applications/{applicationUuid}/code", 'get', '200'); $this->clientProphecy->request( 'get', "/applications/$applicationResponse->uuid/code" ) - ->willReturn($codeResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($codeResponse->_embedded->items) + ->shouldBeCalled(); $databasesResponse = $this->getMockResponseFromSpec("/applications/{applicationUuid}/databases", 'get', '200'); $this->clientProphecy->request( 'get', "/applications/$applicationResponse->uuid/databases" ) - ->willReturn($databasesResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($databasesResponse->_embedded->items) + ->shouldBeCalled(); $environmentsResponse = $this->getMockResponseFromSpec( '/applications/{applicationUuid}/environments', @@ -57,8 +57,8 @@ private function setupCdeTest(string $label): string 202 ); $this->clientProphecy->request('post', "/applications/$applicationResponse->uuid/environments", Argument::type('array')) - ->willReturn($environmentsResponse->{'Adding environment'}->value) - ->shouldBeCalled(); + ->willReturn($environmentsResponse->{'Adding environment'}->value) + ->shouldBeCalled(); $this->mockNotificationResponseFromObject($environmentsResponse->{'Adding environment'}->value); return $response2->_embedded->items[3]->domains[0]; @@ -93,11 +93,11 @@ public function providerTestCreateCde(): array $application = $this->getApplication(); $branch = $this->getBranch(); return [ - // No args, only interactive input. + // No args, only interactive input. [[null, null], ['n', 0, 0]], - // Branch as arg. + // Branch as arg. [[$branch, null], ['n', 0]], - // Branch and app id as args. + // Branch and app id as args. [[$branch, $application], []], ]; } diff --git a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php index 2bb6a0aa3..deb1eb431 100644 --- a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php @@ -53,8 +53,8 @@ public function testDeleteCde(mixed $environmentId): void 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn($response2->_embedded->items) - ->shouldBeCalled(); + ->willReturn($response2->_embedded->items) + ->shouldBeCalled(); $environmentsResponse = $this->getMockResponseFromSpec( '/environments/{environmentId}', @@ -62,8 +62,8 @@ public function testDeleteCde(mixed $environmentId): void 202 ); $this->clientProphecy->request('delete', "/environments/" . $cde->id) - ->willReturn($environmentsResponse) - ->shouldBeCalled(); + ->willReturn($environmentsResponse) + ->shouldBeCalled(); $this->getMockResponseFromSpec( '/environments/{environmentId}', @@ -71,17 +71,17 @@ public function testDeleteCde(mixed $environmentId): void 200 ); $this->clientProphecy->request('get', "/environments/" . $cde->id) - ->willReturn($cde) - ->shouldBeCalled(); + ->willReturn($cde) + ->shouldBeCalled(); $this->executeCommand( [ 'environmentId' => $environmentId, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. + // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. 'n', - // Select a Cloud Platform application: [Sample application 1]: + // Select a Cloud Platform application: [Sample application 1]: 0, ] ); @@ -105,9 +105,9 @@ public function testNoExistingCDEEnvironment(): void $this->executeCommand( [], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. + // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. 'n', - // Select a Cloud Platform application: [Sample application 1]: + // Select a Cloud Platform application: [Sample application 1]: 0, ] ); @@ -128,8 +128,8 @@ public function testNoEnvironmentArgumentPassed(): void 'get', "/applications/{$application->uuid}/environments" ) - ->willReturn($environments) - ->shouldBeCalled(); + ->willReturn($environments) + ->shouldBeCalled(); $cde = $environments[0]; $environmentsResponse = $this->getMockResponseFromSpec( @@ -138,15 +138,15 @@ public function testNoEnvironmentArgumentPassed(): void 202 ); $this->clientProphecy->request('delete', "/environments/" . $cde->id) - ->willReturn($environmentsResponse) - ->shouldBeCalled(); + ->willReturn($environmentsResponse) + ->shouldBeCalled(); $this->executeCommand( [], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. + // Would you like Acquia CLI to search for a Cloud application that matches your local git config?'. 'n', - // Select a Cloud Platform application: [Sample application 1]: + // Select a Cloud Platform application: [Sample application 1]: 0, ] ); diff --git a/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php b/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php index 975ccd8f7..1f1d8c987 100644 --- a/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvMirrorCommandTest.php @@ -35,16 +35,16 @@ public function testEnvironmentMirror(): void ], ] ) - ->willReturn($response) - ->shouldBeCalled(); + ->willReturn($response) + ->shouldBeCalled(); $databasesResponse = $this->getMockResponseFromSpec("/environments/{environmentId}/databases", 'get', '200'); $this->clientProphecy->request( 'get', "/environments/{$environmentResponse->id}/databases" ) - ->willReturn($databasesResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($databasesResponse->_embedded->items) + ->shouldBeCalled(); $dbCopyResponse = $this->getMockResponseFromSpec("/environments/{environmentId}/databases", 'post', '202'); $response = $dbCopyResponse->{'Database being copied'}->value; @@ -56,8 +56,8 @@ public function testEnvironmentMirror(): void 'source' => $environmentResponse->id, ], ]) - ->willReturn($response) - ->shouldBeCalled(); + ->willReturn($response) + ->shouldBeCalled(); $filesCopyResponse = $this->getMockResponseFromSpec("/environments/{environmentId}/files", 'post', '202'); $response = $filesCopyResponse->{'Files queued for copying'}->value; @@ -68,13 +68,13 @@ public function testEnvironmentMirror(): void 'source' => $environmentResponse->id, ], ]) - ->willReturn($response) - ->shouldBeCalled(); + ->willReturn($response) + ->shouldBeCalled(); $environmentUpdateResponse = $this->getMockResponseFromSpec("/environments/{environmentId}", 'put', '202'); $this->clientProphecy->request('put', "/environments/{$environmentResponse->id}", Argument::type('array')) - ->willReturn($environmentUpdateResponse) - ->shouldBeCalled(); + ->willReturn($environmentUpdateResponse) + ->shouldBeCalled(); $this->mockNotificationResponseFromObject($environmentUpdateResponse); $this->executeCommand( @@ -83,7 +83,7 @@ public function testEnvironmentMirror(): void 'source-environment' => $environmentResponse->id, ], [ - // Are you sure that you want to overwrite everything ... + // Are you sure that you want to overwrite everything ... 'y', ] ); diff --git a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php index 34834f783..a30566941 100644 --- a/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php @@ -57,15 +57,17 @@ public function testCreate(): void /** @var \Prophecy\Prophecy\ObjectProphecy|\GuzzleHttp\Psr7\Response $guzzleResponse */ $guzzleResponse = $this->prophet->prophesize(Response::class); $guzzleResponse->getStatusCode()->willReturn(200); - $this->httpClientProphecy->request('GET', 'https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com/health', ['http_errors' => false])->willReturn($guzzleResponse->reveal())->shouldBeCalled(); + $this->httpClientProphecy->request('GET', 'https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com/health', ['http_errors' => false]) + ->willReturn($guzzleResponse->reveal()) + ->shouldBeCalled(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? - // Would you like to link the project at ... ? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like to link the project at ... ? 'n', 0, self::$INPUT_DEFAULT_CHOICE, - // Enter a label for your Cloud IDE: + // Enter a label for your Cloud IDE: 'Example IDE', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php index 0dcc9ca30..7ecf81839 100644 --- a/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeDeleteCommandTest.php @@ -43,15 +43,15 @@ public function testIdeDeleteCommand(): void $this->mockDeleteSshKeyRequest($sshKeyGetResponse->{'_embedded'}->items[0]->uuid); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application for which you'd like to create a new IDE. + // Select the application for which you'd like to create a new IDE. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select the IDE you'd like to delete: + // Select the IDE you'd like to delete: 0, - // Are you sure you want to delete ExampleIDE? + // Are you sure you want to delete ExampleIDE? 'y', ]; @@ -71,7 +71,7 @@ public function testIdeDeleteByUuid(): void $this->mockDeleteSshKeyRequest($sshKeyGetResponse->{'_embedded'}->items[0]->uuid); $inputs = [ - // Would you like to delete the SSH key associated with this IDE from your Cloud Platform account? + // Would you like to delete the SSH key associated with this IDE from your Cloud Platform account? 'y', ]; @@ -88,15 +88,15 @@ public function testIdeDeleteNeverMind(): void $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); $this->mockRequest('getApplicationIdes', $applications[0]->uuid); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application for which you'd like to create a new IDE. + // Select the application for which you'd like to create a new IDE. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select the IDE you'd like to delete: + // Select the IDE you'd like to delete: 0, - // Are you sure you want to delete ExampleIDE? + // Are you sure you want to delete ExampleIDE? 'n', ]; diff --git a/tests/phpunit/src/Commands/Ide/IdeHelper.php b/tests/phpunit/src/Commands/Ide/IdeHelper.php index 41aa6423b..eb8a9d81e 100644 --- a/tests/phpunit/src/Commands/Ide/IdeHelper.php +++ b/tests/phpunit/src/Commands/Ide/IdeHelper.php @@ -9,6 +9,7 @@ class IdeHelper { public static string $remoteIdeUuid = '215824ff-272a-4a8c-9027-df32ed1d68a9'; + public static string $remoteIdeLabel = 'ExampleIDE'; public static function setCloudIdeEnvVars(): void diff --git a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php index 6f9ba1f89..3c13937e5 100644 --- a/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeInfoCommandTest.php @@ -28,13 +28,13 @@ public function testIdeInfoCommand(): void $ides = $this->mockRequest('getApplicationIdes', $applications[0]->uuid); $this->mockRequest('getIde', $ides[0]->uuid); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select an IDE ... + // Select an IDE ... 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php index a9a658167..a87fadc69 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php @@ -28,16 +28,16 @@ public function testIdeListMineCommand(): void $appUuid = end($appUrlParts); $applicationResponse->uuid = $appUuid; $this->clientProphecy->request('get', '/applications/' . $appUuid) - ->willReturn($applicationResponse) - ->shouldBeCalled(); + ->willReturn($applicationResponse) + ->shouldBeCalled(); } $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', ]; $this->executeCommand([], $inputs); @@ -70,8 +70,8 @@ protected function mockAccountIdeListRequest(): object 'get', '/account/ides' ) - ->willReturn($response->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($response->{'_embedded'}->items) + ->shouldBeCalled(); return $response; } diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php index 95b9475c4..28e0909bc 100644 --- a/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeListCommandTest.php @@ -27,11 +27,11 @@ public function testIdeListCommand(): void $application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); $this->mockRequest('getApplicationIdes', $application->uuid); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', ]; $this->executeCommand([], $inputs); @@ -60,15 +60,15 @@ public function testIdeListEmptyCommand(): void 'get', '/applications/a47ac10b-58cc-4372-a567-0e02b2c3d470/ides' ) - ->willReturn([]) - ->shouldBeCalled(); + ->willReturn([]) + ->shouldBeCalled(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select the application. + // Select the application. self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php index 2864d1f1d..4326d1c88 100644 --- a/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeOpenCommandTest.php @@ -28,16 +28,17 @@ public function testIdeOpenCommand(): void $this->mockRequest('getApplicationIdes', $applications[0]->uuid); $localMachineHelper = $this->mockLocalMachineHelper(); $localMachineHelper->isBrowserAvailable()->willReturn(true); - $localMachineHelper->startBrowser('https://9a83c081-ef78-4dbd-8852-11cc3eb248f7.ides.acquia.com')->willReturn(true); + $localMachineHelper->startBrowser('https://9a83c081-ef78-4dbd-8852-11cc3eb248f7.ides.acquia.com') + ->willReturn(true); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Select the IDE you'd like to open: + // Select the IDE you'd like to open: 0, ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php index 30439e738..e292379c1 100644 --- a/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdePhpVersionCommandTest.php @@ -50,7 +50,8 @@ public function testIdePhpVersionCommand(string $version): void $phpStubFilepath = $phpFilepathPrefix . $version; $mockFileSystem->exists($phpStubFilepath)->willReturn(true); $phpVersionFilePath = $this->fs->tempnam(sys_get_temp_dir(), 'acli_php_version_file_'); - $mockFileSystem->dumpFile($phpVersionFilePath, $version)->shouldBeCalled(); + $mockFileSystem->dumpFile($phpVersionFilePath, $version) + ->shouldBeCalled(); $this->command->setPhpVersionFilePath($phpVersionFilePath); $this->command->setIdePhpFilePathPrefix($phpFilepathPrefix); @@ -112,7 +113,9 @@ protected function mockRestartPhp(ObjectProphecy|LocalMachineHelper $localMachin protected function mockGetFilesystem(ObjectProphecy|LocalMachineHelper $localMachineHelper): ObjectProphecy|Filesystem { $fileSystem = $this->prophet->prophesize(Filesystem::class); - $localMachineHelper->getFilesystem()->willReturn($fileSystem)->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($fileSystem) + ->shouldBeCalled(); return $fileSystem; } diff --git a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php index 83363d27b..32a64b4f1 100644 --- a/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/IdeXdebugToggleCommandTest.php @@ -29,13 +29,13 @@ public function setUpXdebug(string $phpVersion): void $process->getExitCode()->willReturn(0); $localMachineHelper = $this->mockLocalMachineHelper(); $localMachineHelper - ->execute([ - 'supervisorctl', - 'restart', - 'php-fpm', - ], null, null, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute([ + 'supervisorctl', + 'restart', + 'php-fpm', + ], null, null, false) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function createCommand(): CommandBase diff --git a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php index ac0575bca..cc454cbb5 100644 --- a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardCreateSshKeyCommandTest.php @@ -9,7 +9,8 @@ use Acquia\Cli\Tests\Commands\Ide\IdeHelper; /** - * @property \Acquia\Cli\Command\Ide\Wizard\IdeWizardCreateSshKeyCommand $command + * @property \Acquia\Cli\Command\Ide\Wizard\IdeWizardCreateSshKeyCommand + * $command * @requires OS linux|darwin */ class IdeWizardCreateSshKeyCommandTest extends IdeWizardTestBase diff --git a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php index 13a1ae503..e02489cd4 100644 --- a/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php +++ b/tests/phpunit/src/Commands/Ide/Wizard/IdeWizardDeleteSshKeyCommandTest.php @@ -9,7 +9,8 @@ use Acquia\Cli\Tests\Commands\Ide\IdeHelper; /** - * @property \Acquia\Cli\Command\Ide\Wizard\IdeWizardCreateSshKeyCommand $command + * @property \Acquia\Cli\Command\Ide\Wizard\IdeWizardCreateSshKeyCommand + * $command */ class IdeWizardDeleteSshKeyCommandTest extends IdeWizardTestBase { diff --git a/tests/phpunit/src/Commands/InferApplicationTest.php b/tests/phpunit/src/Commands/InferApplicationTest.php index afb39f52b..09efd64a0 100644 --- a/tests/phpunit/src/Commands/InferApplicationTest.php +++ b/tests/phpunit/src/Commands/InferApplicationTest.php @@ -36,13 +36,13 @@ public function testInfer(): void 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn([$environmentResponse, $environmentResponse2]) - ->shouldBeCalled(); + ->willReturn([$environmentResponse, $environmentResponse2]) + ->shouldBeCalled(); $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // 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 ... + // Would you like to link the project at ... 'y', ]); @@ -65,21 +65,21 @@ public function testInferFailure(): void 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn([$environmentResponse, $environmentResponse]) - ->shouldBeCalled(); + ->willReturn([$environmentResponse, $environmentResponse]) + ->shouldBeCalled(); $this->clientProphecy->request( 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[1]->uuid}/environments" ) - ->willReturn([$environmentResponse, $environmentResponse]) - ->shouldBeCalled(); + ->willReturn([$environmentResponse, $environmentResponse]) + ->shouldBeCalled(); $this->executeCommand([], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'y', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... + // Would you like to link the project at ... 'y', ]); diff --git a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php index fb396a67a..e9defea1b 100644 --- a/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCodeCommandTest.php @@ -50,19 +50,20 @@ public function testCloneRepo(): void $process = $this->mockProcess(); $dir = Path::join($this->vfsRoot->url(), 'empty-dir'); mkdir($dir); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $this->mockExecuteGitClone($localMachineHelper, $environment, $process, $dir); $this->mockExecuteGitCheckout($localMachineHelper, $environment->vcs->path, $dir, $process); $localMachineHelper->getFinder()->willReturn(new Finder()); $inputs = [ - // Would you like to clone a project into the current directory? + // Would you like to clone a project into the current directory? 'y', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: self::$INPUT_DEFAULT_CHOICE, ]; $this->executeCommand([ @@ -77,7 +78,8 @@ public function testPullCode(): void $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -104,7 +106,8 @@ public function testWithScripts(): void $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -134,7 +137,8 @@ public function testNoComposerJson(): void $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -161,7 +165,8 @@ public function testNoComposer(): void $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -170,9 +175,9 @@ public function testNoComposer(): void $this->mockExecuteGitStatus(false, $localMachineHelper, $this->projectDir); $process = $this->mockProcess(); $localMachineHelper - ->commandExists('composer') - ->willReturn(false) - ->shouldBeCalled(); + ->commandExists('composer') + ->willReturn(false) + ->shouldBeCalled(); $this->mockExecuteDrushExists($localMachineHelper); $this->mockExecuteDrushStatus($localMachineHelper, $this->projectDir); $this->mockExecuteDrushCacheRebuild($localMachineHelper, $process); @@ -194,7 +199,8 @@ public function testWithVendorDir(): void $this->createMockGitConfigFile(); $localMachineHelper = $this->mockReadIdePhpVersion(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -241,7 +247,7 @@ public function testMatchPhpVersion(string $phpVersion): void $localMachineHelper = $this->mockReadIdePhpVersion($phpVersion); $localMachineHelper->checkRequiredBinariesExist(["git"]) - ->shouldBeCalled(); + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); @@ -256,18 +262,18 @@ public function testMatchPhpVersion(string $phpVersion): void 'get', "/environments/" . $environmentResponse->id ) - ->willReturn($environmentResponse) - ->shouldBeCalled(); + ->willReturn($environmentResponse) + ->shouldBeCalled(); $this->executeCommand([ '--dir' => $dir, '--no-scripts' => true, - // @todo Execute ONLY match php aspect, not the code pull. + // @todo Execute ONLY match php aspect, not the code pull. 'environmentId' => $environmentResponse->id, ], [ - // Choose an Acquia environment: + // Choose an Acquia environment: self::$INPUT_DEFAULT_CHOICE, - // Would you like to change the PHP version on this IDE to match the PHP version on ... ? + // Would you like to change the PHP version on this IDE to match the PHP version on ... ? 'n', ]); @@ -294,7 +300,7 @@ protected function mockExecuteGitClone( $dir, ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true, null, ['GIT_SSH_COMMAND' => 'ssh -o StrictHostKeyChecking=no']) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/Pull/PullCommandTest.php b/tests/phpunit/src/Commands/Pull/PullCommandTest.php index 7e22962c7..1a972a8c8 100644 --- a/tests/phpunit/src/Commands/Pull/PullCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullCommandTest.php @@ -40,7 +40,8 @@ public function testPull(): void $environment = $this->mockGetEnvironment(); $this->createMockGitConfigFile(); $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["git"]) + ->shouldBeCalled(); $finder = $this->mockFinder(); $localMachineHelper->getFinder()->willReturn($finder->reveal()); $process = $this->mockProcess(); @@ -62,20 +63,20 @@ public function testPull(): void $this->mockExecuteMySqlListTables($localMachineHelper, 'drupal'); $process = $this->mockProcess(); $localMachineHelper - ->execute(Argument::type('array'), Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute(Argument::type('array'), Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) + ->willReturn($process->reveal()) + ->shouldBeCalled(); $this->mockExecuteMySqlImport($localMachineHelper, true, true, 'my_db', 'my_dbdev', 'drupal'); $this->executeCommand([ '--no-scripts' => true, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: self::$INPUT_DEFAULT_CHOICE, self::$INPUT_DEFAULT_CHOICE, ]); @@ -100,7 +101,7 @@ public function testMissingLocalRepo(): void $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage('Execute this command from within a Drupal project directory or an empty directory'); $inputs = [ - // Would you like to clone a project into the current directory? + // Would you like to clone a project into the current directory? 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php b/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php index 0dc9022f6..22bb890a7 100644 --- a/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php +++ b/tests/phpunit/src/Commands/Pull/PullCommandTestBase.php @@ -27,13 +27,21 @@ abstract class PullCommandTestBase extends CommandTestBase protected Client|ObjectProphecy $httpClientProphecy; protected string $dbUser = 'drupal'; + protected string $dbPassword = 'drupal'; + protected string $dbHost = 'localhost'; + protected string $dbName = 'drupal'; public function setUp(): void { - self::unsetEnvVars(['ACLI_DB_HOST', 'ACLI_DB_USER', 'ACLI_DB_PASSWORD', 'ACLI_DB_NAME']); + self::unsetEnvVars([ + 'ACLI_DB_HOST', + 'ACLI_DB_USER', + 'ACLI_DB_PASSWORD', + 'ACLI_DB_NAME', + ]); parent::setUp(); } @@ -41,9 +49,9 @@ protected function mockExecuteDrushExists( ObjectProphecy $localMachineHelper ): void { $localMachineHelper - ->commandExists('drush') - ->willReturn(true) - ->shouldBeCalled(); + ->commandExists('drush') + ->willReturn(true) + ->shouldBeCalled(); } protected function mockExecuteDrushStatus( @@ -54,17 +62,17 @@ protected function mockExecuteDrushStatus( $drushStatusProcess->isSuccessful()->willReturn(true); $drushStatusProcess->getExitCode()->willReturn(0); $drushStatusProcess->getOutput() - ->willReturn(json_encode(['db-status' => 'Connected'])); + ->willReturn(json_encode(['db-status' => 'Connected'])); $localMachineHelper - ->execute([ - 'drush', - 'status', - '--fields=db-status,drush-version', - '--format=json', - '--no-interaction', - ], Argument::any(), $dir, false) - ->willReturn($drushStatusProcess->reveal()) - ->shouldBeCalled(); + ->execute([ + 'drush', + 'status', + '--fields=db-status,drush-version', + '--format=json', + '--no-interaction', + ], Argument::any(), $dir, false) + ->willReturn($drushStatusProcess->reveal()) + ->shouldBeCalled(); } protected function mockExecuteDrushCacheRebuild( @@ -72,15 +80,15 @@ protected function mockExecuteDrushCacheRebuild( ObjectProphecy $process ): void { $localMachineHelper - ->execute([ - 'drush', - 'cache:rebuild', - '--yes', - '--no-interaction', - '--verbose', - ], Argument::type('callable'), $this->projectDir, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute([ + 'drush', + 'cache:rebuild', + '--yes', + '--no-interaction', + '--verbose', + ], Argument::type('callable'), $this->projectDir, false) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteDrushSqlSanitize( @@ -88,24 +96,24 @@ protected function mockExecuteDrushSqlSanitize( ObjectProphecy $process ): void { $localMachineHelper - ->execute([ - 'drush', - 'sql:sanitize', - '--yes', - '--no-interaction', - '--verbose', - ], Argument::type('callable'), $this->projectDir, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute([ + 'drush', + 'sql:sanitize', + '--yes', + '--no-interaction', + '--verbose', + ], Argument::type('callable'), $this->projectDir, false) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteComposerExists( ObjectProphecy $localMachineHelper ): void { $localMachineHelper - ->commandExists('composer') - ->willReturn(true) - ->shouldBeCalled(); + ->commandExists('composer') + ->willReturn(true) + ->shouldBeCalled(); } protected function mockExecuteComposerInstall( @@ -113,22 +121,22 @@ protected function mockExecuteComposerInstall( ObjectProphecy $process ): void { $localMachineHelper - ->execute([ - 'composer', - 'install', - '--no-interaction', - ], Argument::type('callable'), $this->projectDir, false, null) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute([ + 'composer', + 'install', + '--no-interaction', + ], Argument::type('callable'), $this->projectDir, false, null) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockDrupalSettingsRefresh( ObjectProphecy $localMachineHelper ): void { $localMachineHelper - ->execute([ - '/ide/drupal-setup.sh', - ]); + ->execute([ + '/ide/drupal-setup.sh', + ]); } protected function mockExecuteGitStatus( @@ -138,7 +146,9 @@ protected function mockExecuteGitStatus( ): void { $process = $this->prophet->prophesize(Process::class); $process->isSuccessful()->willReturn(!$failed)->shouldBeCalled(); - $localMachineHelper->executeFromCmd('git add . && git diff-index --cached --quiet HEAD', null, $cwd, false)->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->executeFromCmd('git add . && git diff-index --cached --quiet HEAD', null, $cwd, false) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockGetLocalCommitHash( @@ -185,8 +195,8 @@ protected function mockExecuteGitFetchAndCheckout( 'fetch', '--all', ], Argument::type('callable'), $cwd, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); $this->mockExecuteGitCheckout($localMachineHelper, $vcsPath, $cwd, $process); } @@ -197,8 +207,8 @@ protected function mockExecuteGitCheckout(ObjectProphecy $localMachineHelper, st 'checkout', $vcsPath, ], Argument::type('callable'), $cwd, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteRsync( @@ -208,7 +218,8 @@ protected function mockExecuteRsync( string $destinationDir ): void { $process = $this->mockProcess(); - $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['rsync']) + ->shouldBeCalled(); $command = [ 'rsync', '-avPhze', @@ -217,34 +228,36 @@ protected function mockExecuteRsync( $destinationDir, ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteMySqlConnect( ObjectProphecy $localMachineHelper, bool $success ): void { - $localMachineHelper->checkRequiredBinariesExist(["mysql"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["mysql"]) + ->shouldBeCalled(); $process = $this->mockProcess($success); $localMachineHelper - ->execute([ - 'mysql', - '--host', - $this->dbHost, - '--user', - 'drupal', - 'drupal', - ], Argument::type('callable'), null, false, null, ['MYSQL_PWD' => 'drupal']) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute([ + 'mysql', + '--host', + $this->dbHost, + '--user', + 'drupal', + 'drupal', + ], Argument::type('callable'), null, false, null, ['MYSQL_PWD' => 'drupal']) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteMySqlListTables( LocalMachineHelper|ObjectProphecy $localMachineHelper, string $dbName = 'jxr5000596dev', ): void { - $localMachineHelper->checkRequiredBinariesExist(["mysql"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["mysql"]) + ->shouldBeCalled(); $process = $this->mockProcess(); $process->getOutput()->willReturn('table1'); $command = [ @@ -259,9 +272,9 @@ protected function mockExecuteMySqlListTables( 'SHOW TABLES;', ]; $localMachineHelper - ->execute($command, Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($command, Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteMySqlDropDb( @@ -269,14 +282,17 @@ protected function mockExecuteMySqlDropDb( bool $success, ObjectProphecy $fs ): void { - $localMachineHelper->checkRequiredBinariesExist(["mysql"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["mysql"]) + ->shouldBeCalled(); $process = $this->mockProcess($success); - $fs->tempnam(Argument::type('string'), 'acli_drop_table_', '.sql')->willReturn('something')->shouldBeCalled(); + $fs->tempnam(Argument::type('string'), 'acli_drop_table_', '.sql') + ->willReturn('something') + ->shouldBeCalled(); $fs->dumpfile('something', Argument::type('string'))->shouldBeCalled(); $localMachineHelper - ->execute(Argument::type('array'), Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute(Argument::type('array'), Argument::type('callable'), null, false, null, ['MYSQL_PWD' => $this->dbPassword]) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteMySqlImport( @@ -288,22 +304,23 @@ protected function mockExecuteMySqlImport( string $localDbName = 'jxr5000596dev', string $env = 'dev' ): void { - $localMachineHelper->checkRequiredBinariesExist(['gunzip', 'mysql'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['gunzip', 'mysql']) + ->shouldBeCalled(); $this->mockExecutePvExists($localMachineHelper, $pvExists); $process = $this->mockProcess($success); $filePath = Path::join(sys_get_temp_dir(), "$env-$dbName-$dbMachineName-2012-05-15T12:00:00.000Z.sql.gz"); $command = $pvExists ? "pv $filePath --bytes --rate | gunzip | MYSQL_PWD=drupal mysql --host=localhost --user=drupal $localDbName" : "gunzip -c $filePath | MYSQL_PWD=drupal mysql --host=localhost --user=drupal $localDbName"; // MySQL import command. $localMachineHelper - ->executeFromCmd( - $command, - Argument::type('callable'), - null, - true, - null - ) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->executeFromCmd( + $command, + Argument::type('callable'), + null, + true, + null + ) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockDownloadMySqlDump(ObjectProphecy $localMachineHelper, mixed $success): void @@ -313,22 +330,25 @@ protected function mockDownloadMySqlDump(ObjectProphecy $localMachineHelper, mix Argument::containingString("dev-profserv2-profserv201dev-something.sql.gz"), 'backupfilecontents' ) - ->shouldBeCalled(); + ->shouldBeCalled(); } protected function mockSettingsFiles(ObjectProphecy $fs): void { $fs->remove(Argument::type('string')) - ->willReturn() - ->shouldBeCalled(); + ->willReturn() + ->shouldBeCalled(); } protected function mockListSites(SshHelper|ObjectProphecy $sshHelper): void { $process = $this->mockProcess(); $process->getOutput()->willReturn('default')->shouldBeCalled(); - $sshHelper->executeCommand(Argument::type('string'), ['ls', '/mnt/files/site.dev/sites'], false) - ->willReturn($process->reveal())->shouldBeCalled(); + $sshHelper->executeCommand(Argument::type('string'), [ + 'ls', + '/mnt/files/site.dev/sites', + ], false) + ->willReturn($process->reveal())->shouldBeCalled(); } public function mockGetBackup(mixed $environment): void @@ -352,14 +372,18 @@ protected function mockDownloadBackup(object $database, object $environment, obj $this->prophet->prophesize(StreamInterface::class); /** @var RequestException|ObjectProphecy $requestException */ $requestException = $this->prophet->prophesize(RequestException::class); - $requestException->getHandlerContext()->willReturn(['errno' => $curlCode]); + $requestException->getHandlerContext() + ->willReturn(['errno' => $curlCode]); $this->clientProphecy->stream('get', "/environments/{$environment->id}/databases/{$database->name}/backups/1/actions/download", []) - ->willThrow($requestException->reveal()) - ->shouldBeCalled(); + ->willThrow($requestException->reveal()) + ->shouldBeCalled(); $response = $this->prophet->prophesize(ResponseInterface::class); - $this->httpClientProphecy->request('GET', 'https://other.example.com/download-backup', Argument::type('array'))->willReturn($response->reveal())->shouldBeCalled(); + $this->httpClientProphecy->request('GET', 'https://other.example.com/download-backup', Argument::type('array')) + ->willReturn($response->reveal()) + ->shouldBeCalled(); $domainsResponse = $this->getMockResponseFromSpec('/environments/{environmentId}/domains', 'get', 200); - $this->clientProphecy->request('get', "/environments/{$environment->id}/domains")->willReturn($domainsResponse->_embedded->items); + $this->clientProphecy->request('get', "/environments/{$environment->id}/domains") + ->willReturn($domainsResponse->_embedded->items); $this->command->setBackupDownloadUrl(new Uri('https://www.example.com/download-backup')); } else { $this->mockDownloadBackupResponse($environment, $database->name, 1); @@ -376,13 +400,16 @@ protected function mockDownloadBackup(object $database, object $environment, obj $backup->completedAt, ]) . '.sql.gz'; $localFilepath = Path::join(sys_get_temp_dir(), $filename); - $this->clientProphecy->addOption('sink', $localFilepath)->shouldBeCalled(); + $this->clientProphecy->addOption('sink', $localFilepath) + ->shouldBeCalled(); $this->clientProphecy->addOption('curl.options', [ 'CURLOPT_FILE' => $localFilepath, 'CURLOPT_RETURNTRANSFER' => false, ])->shouldBeCalled(); - $this->clientProphecy->addOption('progress', Argument::type('Closure'))->shouldBeCalled(); - $this->clientProphecy->addOption('on_stats', Argument::type('Closure'))->shouldBeCalled(); + $this->clientProphecy->addOption('progress', Argument::type('Closure')) + ->shouldBeCalled(); + $this->clientProphecy->addOption('on_stats', Argument::type('Closure')) + ->shouldBeCalled(); $this->clientProphecy->getOptions()->willReturn([]); return $database; diff --git a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php index 5b9705c6c..da95bb0dd 100644 --- a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php @@ -92,8 +92,11 @@ public function testPullProdDatabase(): void $sshHelper = $this->mockSshHelper(); $process = $this->mockProcess(); $process->getOutput()->willReturn('default')->shouldBeCalled(); - $sshHelper->executeCommand(Argument::type('string'), ['ls', '/mnt/files/site.prod/sites'], false) - ->willReturn($process->reveal())->shouldBeCalled(); + $sshHelper->executeCommand(Argument::type('string'), [ + 'ls', + '/mnt/files/site.prod/sites', + ], false) + ->willReturn($process->reveal())->shouldBeCalled(); $this->mockGetBackup($environment); $this->mockExecuteMySqlListTables($localMachineHelper, 'drupal'); $fs = $this->prophet->prophesize(Filesystem::class); @@ -105,13 +108,13 @@ public function testPullProdDatabase(): void $this->executeCommand([ '--no-scripts' => true, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: 1, ]); @@ -166,17 +169,17 @@ public function testPullMultipleDatabases(): void { $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? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose a Cloud Platform environment [Dev, dev (vcs: master)]: + // Choose a Cloud Platform environment [Dev, dev (vcs: master)]: 0, - // Choose a site [jxr5000596dev (oracletest1.dev-profserv2.acsitefactory.com)]: + // Choose a site [jxr5000596dev (oracletest1.dev-profserv2.acsitefactory.com)]: 0, - // Choose databases. You may choose multiple. Use commas to separate choices. [profserv2 (default)]: + // Choose databases. You may choose multiple. Use commas to separate choices. [profserv2 (default)]: '10,27', ]; $this->executeCommand([ @@ -390,13 +393,13 @@ public function testPullNode(): void $this->executeCommand([ '--no-scripts' => true, ], [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: self::$INPUT_DEFAULT_CHOICE, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: 1, ]); } diff --git a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php index eab9c305b..85e2b6ca1 100644 --- a/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php @@ -46,15 +46,15 @@ public function testRefreshAcsfFiles(): void $this->command->sshHelper = $sshHelper->reveal(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, - // Choose site from which to copy files: + // Choose site from which to copy files: 0, ]; @@ -85,15 +85,15 @@ public function testRefreshCloudFiles(): void $this->command->sshHelper = $sshHelper->reveal(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, - // Choose site from which to copy files: + // Choose site from which to copy files: 0, ]; diff --git a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php index 1e0bcaef2..9215b723b 100644 --- a/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullScriptsCommandTest.php @@ -35,13 +35,13 @@ public function testRefreshScripts(): void $this->mockExecuteDrushSqlSanitize($localMachineHelper, $process); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, ]; diff --git a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php index ada794d0f..1b5bf8aa9 100644 --- a/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php @@ -52,13 +52,13 @@ public function testPushArtifact(int $verbosity, bool $printOutput): void $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, true, $printOutput); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, ]; $this->executeCommand([], $inputs, $verbosity); @@ -100,11 +100,11 @@ public function testPushTagArtifact(): void $artifactDir = Path::join(sys_get_temp_dir(), 'acli-push-artifact'); $this->mockGitTag($localMachineHelper, $gitTag, $artifactDir); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', ]; $this->executeCommand([ @@ -171,13 +171,13 @@ public function testPushArtifactNoPush(): void $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, ]; $this->executeCommand(['--no-push' => true], $inputs); @@ -197,13 +197,13 @@ public function testPushArtifactNoCommit(): void $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, false, false); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, ]; $this->executeCommand(['--no-commit' => true], $inputs); @@ -220,13 +220,13 @@ public function testPushArtifactNoClone(): void $localMachineHelper = $this->mockLocalMachineHelper(); $this->setUpPushArtifact($localMachineHelper, 'nothing', [], 'something', false, false, false); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', - // Choose an Acquia environment: + // Choose an Acquia environment: 0, ]; $this->executeCommand(['--no-clone' => true], $inputs); @@ -254,7 +254,8 @@ protected function setUpPushArtifact(ObjectProphecy $localMachineHelper, string $this->mockGetLocalCommitHash($localMachineHelper, $this->projectDir, $commitHash); $this->mockComposerInstall($localMachineHelper, $artifactDir, $printOutput); $this->mockReadComposerJson($localMachineHelper, $artifactDir); - $localMachineHelper->checkRequiredBinariesExist(['git'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['git']) + ->shouldBeCalled(); if ($clone) { $this->mockLocalGitConfig($localMachineHelper, $artifactDir, $printOutput); @@ -272,47 +273,112 @@ protected function mockCloneShallow(ObjectProphecy $localMachineHelper, string $ { $process = $this->prophet->prophesize(Process::class); $process->isSuccessful()->willReturn(true)->shouldBeCalled(); - $localMachineHelper->execute(['git', 'clone', '--depth=1', $vcsUrl, $artifactDir], Argument::type('callable'), null, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'fetch', '--depth=1', '--update-head-ok', $vcsUrl, $vcsPath . ':' . $vcsPath], Argument::type('callable'), Argument::type('string'), $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'checkout', $vcsPath], Argument::type('callable'), Argument::type('string'), $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'clone', + '--depth=1', + $vcsUrl, + $artifactDir, + ], Argument::type('callable'), null, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'fetch', + '--depth=1', + '--update-head-ok', + $vcsUrl, + $vcsPath . ':' . $vcsPath, + ], Argument::type('callable'), Argument::type('string'), $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'checkout', + $vcsPath, + ], Argument::type('callable'), Argument::type('string'), $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); } protected function mockLocalGitConfig(ObjectProphecy $localMachineHelper, string $artifactDir, bool $printOutput = true): void { $process = $this->prophet->prophesize(Process::class); - $localMachineHelper->execute(['git', 'config', '--local', 'core.excludesFile', 'false'], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'config', '--local', 'core.fileMode', 'true'], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'config', + '--local', + 'core.excludesFile', + 'false', + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'config', + '--local', + 'core.fileMode', + 'true', + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); } protected function mockComposerInstall(ObjectProphecy $localMachineHelper, mixed $artifactDir, bool $printOutput = true): void { - $localMachineHelper->checkRequiredBinariesExist(['composer'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['composer']) + ->shouldBeCalled(); $process = $this->prophet->prophesize(Process::class); $process->isSuccessful()->willReturn(true); - $localMachineHelper->execute(['composer', 'install', '--no-dev', '--no-interaction', '--optimize-autoloader'], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'composer', + 'install', + '--no-dev', + '--no-interaction', + '--optimize-autoloader', + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); } protected function mockGitAddCommit(ObjectProphecy $localMachineHelper, string $artifactDir, string $commitHash, bool $printOutput): void { $process = $this->mockProcess(); - $localMachineHelper->execute(['git', 'add', '-A'], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'add', '-f', 'docroot/index.php'], null, $artifactDir, false) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'add', '-f', 'docroot/autoload.php'], null, $artifactDir, false) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'add', '-f', 'docroot/core'], null, $artifactDir, false) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'add', '-f', 'vendor'], null, $artifactDir, false) - ->willReturn($process->reveal())->shouldBeCalled(); - $localMachineHelper->execute(['git', 'commit', '-m', "Automated commit by Acquia CLI (source commit: $commitHash)"], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'add', + '-A', + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'add', + '-f', + 'docroot/index.php', + ], null, $artifactDir, false) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'add', + '-f', + 'docroot/autoload.php', + ], null, $artifactDir, false) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'add', + '-f', + 'docroot/core', + ], null, $artifactDir, false) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'add', + '-f', + 'vendor', + ], null, $artifactDir, false) + ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'commit', + '-m', + "Automated commit by Acquia CLI (source commit: $commitHash)", + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); } protected function mockReadComposerJson(ObjectProphecy $localMachineHelper, string $artifactDir): void @@ -330,17 +396,22 @@ protected function mockReadComposerJson(ObjectProphecy $localMachineHelper, stri ], ]); $localMachineHelper->readFile(Path::join($this->projectDir, 'composer.json')) - ->willReturn($composerJson); + ->willReturn($composerJson); $localMachineHelper->readFile(Path::join($artifactDir, 'docroot', 'core', 'composer.json')) - ->willReturn($composerJson); + ->willReturn($composerJson); } protected function mockGitPush(array $gitUrls, ObjectProphecy $localMachineHelper, string $artifactDir, string $destGitRef, bool $printOutput): void { $process = $this->mockProcess(); foreach ($gitUrls as $gitUrl) { - $localMachineHelper->execute(['git', 'push', $gitUrl, $destGitRef], Argument::type('callable'), $artifactDir, $printOutput) - ->willReturn($process->reveal())->shouldBeCalled(); + $localMachineHelper->execute([ + 'git', + 'push', + $gitUrl, + $destGitRef, + ], Argument::type('callable'), $artifactDir, $printOutput) + ->willReturn($process->reveal())->shouldBeCalled(); } } @@ -352,6 +423,6 @@ protected function mockGitTag(ObjectProphecy $localMachineHelper, string $gitTag 'tag', $gitTag, ], Argument::type('callable'), $artifactDir, true) - ->willReturn($process->reveal())->shouldBeCalled(); + ->willReturn($process->reveal())->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php index ec295d15c..54e1c4c4d 100644 --- a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php @@ -39,7 +39,12 @@ protected function createCommand(): CommandBase public function setUp(): void { - self::unsetEnvVars(['ACLI_DB_HOST', 'ACLI_DB_USER', 'ACLI_DB_PASSWORD', 'ACLI_DB_NAME']); + self::unsetEnvVars([ + 'ACLI_DB_HOST', + 'ACLI_DB_USER', + 'ACLI_DB_PASSWORD', + 'ACLI_DB_NAME', + ]); parent::setUp(); } @@ -62,7 +67,8 @@ public function testPushDatabase(int $verbosity, bool $printOutput): void $process = $this->mockProcess(); $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->checkRequiredBinariesExist(['ssh'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['ssh']) + ->shouldBeCalled(); $this->mockGetAcsfSitesLMH($localMachineHelper); // Database. @@ -74,17 +80,17 @@ public function testPushDatabase(int $verbosity, bool $printOutput): void $this->command->sshHelper = new SshHelper($this->output, $localMachineHelper->reveal(), $this->logger); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose a Cloud Platform environment. + // Choose a Cloud Platform environment. 0, - // Choose a database. + // Choose a database. 0, - // Overwrite the profserv2 database on dev with a copy of the database from the current machine? + // Overwrite the profserv2 database on dev with a copy of the database from the current machine? 'y', ]; @@ -107,7 +113,8 @@ protected function mockUploadDatabaseDump( ObjectProphecy $process, bool $printOutput = true, ): void { - $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['rsync']) + ->shouldBeCalled(); $command = [ 'rsync', '-tDvPhe', @@ -116,8 +123,8 @@ protected function mockUploadDatabaseDump( 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, $printOutput, null) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteMySqlImport( @@ -126,22 +133,24 @@ protected function mockExecuteMySqlImport( ): void { // MySQL import command. $localMachineHelper - ->executeFromCmd( - Argument::type('string'), - Argument::type('callable'), - null, - true, - null - ) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->executeFromCmd( + Argument::type('string'), + Argument::type('callable'), + null, + true, + null + ) + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockGetAcsfSitesLMH(ObjectProphecy $localMachineHelper): void { $acsfMultisiteFetchProcess = $this->mockProcess(); $multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/multisite-config.json')); - $acsfMultisiteFetchProcess->getOutput()->willReturn($multisiteConfig)->shouldBeCalled(); + $acsfMultisiteFetchProcess->getOutput() + ->willReturn($multisiteConfig) + ->shouldBeCalled(); $cmd = [ 0 => 'ssh', 1 => 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com', @@ -152,7 +161,9 @@ protected function mockGetAcsfSitesLMH(ObjectProphecy $localMachineHelper): void 6 => 'cat', 7 => '/var/www/site-php/profserv2.01dev/multisite-config.json', ]; - $localMachineHelper->execute($cmd, Argument::type('callable'), null, false, null)->willReturn($acsfMultisiteFetchProcess->reveal())->shouldBeCalled(); + $localMachineHelper->execute($cmd, Argument::type('callable'), null, false, null) + ->willReturn($acsfMultisiteFetchProcess->reveal()) + ->shouldBeCalled(); } private function mockImportDatabaseDumpOnRemote(ObjectProphecy|LocalMachineHelper $localMachineHelper, Process|ObjectProphecy $process, bool $printOutput = true): void @@ -167,7 +178,7 @@ private function mockImportDatabaseDumpOnRemote(ObjectProphecy|LocalMachineHelpe 6 => 'pv /mnt/tmp/profserv2.01dev/acli-mysql-dump-drupal.sql.gz --bytes --rate | gunzip | MYSQL_PWD=password mysql --host=fsdb-74.enterprise-g1.hosting.acquia.com.enterprise-g1.hosting.acquia.com --user=s164 profserv2db14390', ]; $localMachineHelper->execute($cmd, Argument::type('callable'), null, $printOutput, null) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php index f238e8f8a..ef671aa01 100644 --- a/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php +++ b/tests/phpunit/src/Commands/Push/PushFilesCommandTest.php @@ -31,17 +31,17 @@ public function testPushFilesAcsf(): void $this->command->sshHelper = $sshHelper->reveal(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose a Cloud Platform environment. + // Choose a Cloud Platform environment. 0, - // Choose a site. + // Choose a site. 0, - // Overwrite the public files directory. + // Overwrite the public files directory. 'y', ]; @@ -70,17 +70,17 @@ public function testPushFilesCloud(): void $this->command->sshHelper = $sshHelper->reveal(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose a Cloud Platform environment. + // Choose a Cloud Platform environment. 0, - // Choose a site. + // Choose a site. 0, - // Overwrite the public files directory. + // Overwrite the public files directory. 'y', ]; @@ -107,17 +107,17 @@ public function testPushFilesNoOverwrite(): void $this->command->sshHelper = $sshHelper->reveal(); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: 0, - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'n', - // Choose a Cloud Platform environment. + // Choose a Cloud Platform environment. 0, - // Choose a site. + // Choose a site. 0, - // Overwrite the public files directory. + // Overwrite the public files directory. 'n', ]; @@ -137,7 +137,8 @@ protected function mockExecuteCloudRsync( ObjectProphecy $process, mixed $environment ): void { - $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['rsync']) + ->shouldBeCalled(); $parts = explode('.', $environment->ssh_url); $sitegroup = reset($parts); $command = [ @@ -148,8 +149,8 @@ protected function mockExecuteCloudRsync( $environment->ssh_url . ':/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/bar/files', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } protected function mockExecuteAcsfRsync( @@ -157,7 +158,8 @@ protected function mockExecuteAcsfRsync( ObjectProphecy $process, string $site ): void { - $localMachineHelper->checkRequiredBinariesExist(['rsync'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['rsync']) + ->shouldBeCalled(); $command = [ 'rsync', '-avPhze', @@ -166,7 +168,7 @@ protected function mockExecuteAcsfRsync( 'profserv2.01dev@profserv201dev.ssh.enterprise-g1.acquia-sites.com:/mnt/files/profserv2.01dev/sites/g/files/' . $site . '/files', ]; $localMachineHelper->execute($command, Argument::type('callable'), null, true) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); } } diff --git a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php index ffccdb5cc..1a4982ee5 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesDownloadCommandTest.php @@ -62,7 +62,8 @@ public function testRemoteAliasesDownloadCommand(array $inputs, array $args, str $stream = Utils::streamFor(file_get_contents($drushAliasesTarballFixtureFilepath . '.tar.gz')); $this->clientProphecy->addQuery('version', $aliasVersion); - $this->clientProphecy->stream('get', '/account/drush-aliases/download')->willReturn($stream); + $this->clientProphecy->stream('get', '/account/drush-aliases/download') + ->willReturn($stream); $drushArchiveFilepath = $this->command->getDrushArchiveTempFilepath(); $destinationDir = $destinationDir ?? Path::join($this->acliRepoRoot, 'drush'); @@ -102,7 +103,8 @@ public function testRemoteAliasesDownloadFailed(): void $stream = Utils::streamFor(file_get_contents($drushAliasesTarballFixtureFilepath . '.tar.gz')); $this->clientProphecy->addQuery('version', '9'); - $this->clientProphecy->stream('get', '/account/drush-aliases/download')->willReturn($stream); + $this->clientProphecy->stream('get', '/account/drush-aliases/download') + ->willReturn($stream); $destinationDir = Path::join($this->acliRepoRoot, 'drush'); $sitesDir = Path::join($destinationDir, 'sites'); @@ -110,6 +112,9 @@ public function testRemoteAliasesDownloadFailed(): void chmod($sitesDir, 000); $this->expectException(AcquiaCliException::class); $this->expectExceptionMessage("Could not extract aliases to $destinationDir"); - $this->executeCommand(['--all' => true, '--destination-dir' => $destinationDir], ['9']); + $this->executeCommand([ + '--all' => true, + '--destination-dir' => $destinationDir, + ], ['9']); } } diff --git a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php index 79358c209..dbd0f7cd9 100644 --- a/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/AliasesListCommandTest.php @@ -25,11 +25,11 @@ public function testRemoteAliasesListCommand(): void $this->mockEnvironmentsRequest($applicationsResponse); $inputs = [ - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? 'n', - // Select a Cloud Platform application: + // Select a Cloud Platform application: '0', - // Would you like to link the project at ... + // Would you like to link the project at ... 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php index 7e7614525..4a60375a0 100644 --- a/tests/phpunit/src/Commands/Remote/DrushCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/DrushCommandTest.php @@ -48,7 +48,8 @@ public function testRemoteDrushCommand(array $args): void { $this->mockGetEnvironment(); [$process, $localMachineHelper] = $this->mockForExecuteCommand(); - $localMachineHelper->checkRequiredBinariesExist(['ssh'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['ssh']) + ->shouldBeCalled(); $sshCommand = [ 'ssh', 'site.dev@sitedev.ssh.hosted.acquia-sites.com', @@ -61,9 +62,9 @@ public function testRemoteDrushCommand(array $args): void '--uri=http://sitedev.hosted.acquia-sites.com status --fields=db-status', ]; $localMachineHelper - ->execute($sshCommand, Argument::type('callable'), null, true, null) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($sshCommand, Argument::type('callable'), null, true, null) + ->willReturn($process->reveal()) + ->shouldBeCalled(); $this->command->sshHelper = new SshHelper($this->output, $localMachineHelper->reveal(), $this->logger); $this->executeCommand($args, self::inputChooseEnvironment()); diff --git a/tests/phpunit/src/Commands/Remote/SshCommandTest.php b/tests/phpunit/src/Commands/Remote/SshCommandTest.php index a6c50048b..60792dc20 100644 --- a/tests/phpunit/src/Commands/Remote/SshCommandTest.php +++ b/tests/phpunit/src/Commands/Remote/SshCommandTest.php @@ -28,7 +28,8 @@ public function testRemoteAliasesDownloadCommand(): void ClearCacheCommand::clearCaches(); $this->mockForGetEnvironmentFromAliasArg(); [$process, $localMachineHelper] = $this->mockForExecuteCommand(); - $localMachineHelper->checkRequiredBinariesExist(['ssh'])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(['ssh']) + ->shouldBeCalled(); $sshCommand = [ 'ssh', 'site.dev@sitedev.ssh.hosted.acquia-sites.com', @@ -39,9 +40,9 @@ public function testRemoteAliasesDownloadCommand(): void 'cd /var/www/html/devcloud2.dev; exec $SHELL -l', ]; $localMachineHelper - ->execute($sshCommand, Argument::type('callable'), null, true, null) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->execute($sshCommand, Argument::type('callable'), null, true, null) + ->willReturn($process->reveal()) + ->shouldBeCalled(); $this->command->sshHelper = new SshHelper($this->output, $localMachineHelper->reveal(), $this->logger); diff --git a/tests/phpunit/src/Commands/Remote/SshCommandTestBase.php b/tests/phpunit/src/Commands/Remote/SshCommandTestBase.php index a9e075baa..b1192a829 100644 --- a/tests/phpunit/src/Commands/Remote/SshCommandTestBase.php +++ b/tests/phpunit/src/Commands/Remote/SshCommandTestBase.php @@ -14,7 +14,8 @@ protected function mockForGetEnvironmentFromAliasArg(): void { $applicationsResponse = $this->mockApplicationsRequest(1); $this->mockEnvironmentsRequest($applicationsResponse); - $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2')->shouldBeCalled(); + $this->clientProphecy->addQuery('filter', 'hosting=@*:devcloud2') + ->shouldBeCalled(); $this->mockRequest('getAccount'); } diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php index b4536da83..e4ec2fd09 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateCommandTest.php @@ -30,7 +30,7 @@ public function providerTestCreate(): array return [ [ true, - // Args. + // Args. [ '--filename' => $this->filename, '--password' => 'acli123', @@ -40,25 +40,25 @@ public function providerTestCreate(): array ], [ true, - // Args. + // Args. [], - // Inputs. + // Inputs. [ - // Enter a filename for your new local SSH key: + // Enter a filename for your new local SSH key: $this->filename, - // Enter a password for your SSH key: + // Enter a password for your SSH key: 'acli123', ], ], [ false, - // Args. + // Args. [], - // Inputs. + // Inputs. [ - // Enter a filename for your new local SSH key: + // Enter a filename for your new local SSH key: $this->filename, - // Enter a password for your SSH key: + // Enter a password for your SSH key: 'acli123', ], ], @@ -74,13 +74,16 @@ public function testCreate(mixed $sshAddSuccess, mixed $args, mixed $inputs): vo $sshKeyFilepath = Path::join($this->sshDir, '/' . $this->filename); $this->fs->remove($sshKeyFilepath); $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->getLocalFilepath('~/.passphrase')->willReturn('~/.passphrase'); + $localMachineHelper->getLocalFilepath('~/.passphrase') + ->willReturn('~/.passphrase'); $fileSystem = $this->prophet->prophesize(Filesystem::class); $this->mockAddSshKeyToAgent($localMachineHelper, $fileSystem); $this->mockSshAgentList($localMachineHelper, $sshAddSuccess); $this->mockGenerateSshKey($localMachineHelper); - $localMachineHelper->getFilesystem()->willReturn($fileSystem->reveal())->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($fileSystem->reveal()) + ->shouldBeCalled(); $this->executeCommand($args, $inputs); } diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php index 14f6aa555..c68247e30 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyCreateUploadCommandTest.php @@ -38,7 +38,8 @@ public function testCreateUpload(): void $sshKeyFilename = 'id_rsa'; $localMachineHelper = $this->mockLocalMachineHelper(); - $localMachineHelper->getLocalFilepath('~/.passphrase')->willReturn('~/.passphrase'); + $localMachineHelper->getLocalFilepath('~/.passphrase') + ->willReturn('~/.passphrase'); $fileSystem = $this->prophet->prophesize(Filesystem::class); $this->mockAddSshKeyToAgent($localMachineHelper, $fileSystem); $this->mockSshAgentList($localMachineHelper); @@ -53,7 +54,9 @@ public function testCreateUpload(): void $this->mockRequest('postAccountSshKeys', null, $body); $this->mockGetLocalSshKey($localMachineHelper, $fileSystem, $mockRequestArgs['public_key']); - $localMachineHelper->getFilesystem()->willReturn($fileSystem->reveal())->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($fileSystem->reveal()) + ->shouldBeCalled(); /** @var SshKeyCreateCommand $sshKeyCreateCommand */ $sshKeyCreateCommand = $this->application->find(SshKeyCreateCommand::getDefaultName()); @@ -63,11 +66,11 @@ public function testCreateUpload(): void $sshKeyUploadCommand->localMachineHelper = $this->command->localMachineHelper; $inputs = [ - // Enter a filename for your new local SSH key: + // Enter a filename for your new local SSH key: $sshKeyFilename, - // Enter a password for your SSH key: + // Enter a password for your SSH key: 'acli123', - // Label. + // Label. $mockRequestArgs['label'], ]; $this->executeCommand(['--no-wait' => ''], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php index 7be735fd0..0417086a0 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyDeleteCommandTest.php @@ -24,9 +24,9 @@ public function testDelete(): void $this->mockRequest('deleteAccountSshKey', $sshKeyListResponse[self::$INPUT_DEFAULT_CHOICE]->uuid, null, 'Removed key'); $inputs = [ - // Choose key. + // Choose key. self::$INPUT_DEFAULT_CHOICE, - // Do you also want to delete the corresponding local key files? + // Do you also want to delete the corresponding local key files? 'n', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php index 1289da0c9..d1501d455 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php @@ -27,7 +27,7 @@ public function testInfo(): void $this->mockListSshKeysRequest(); $inputs = [ - // Choose key. + // Choose key. '0', ]; $this->executeCommand([], $inputs); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php index 984857383..8614cd73a 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyListCommandTest.php @@ -29,7 +29,9 @@ public function testList(): void { $mockBody = $this->getMockResponseFromSpec('/account/ssh-keys', 'get', '200'); - $this->clientProphecy->request('get', '/account/ssh-keys')->willReturn($mockBody->{'_embedded'}->items)->shouldBeCalled(); + $this->clientProphecy->request('get', '/account/ssh-keys') + ->willReturn($mockBody->{'_embedded'}->items) + ->shouldBeCalled(); $mockRequestArgs = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $tempFileName = $this->createLocalSshKey($mockRequestArgs['public_key']); $baseFilename = basename($tempFileName); diff --git a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php index 4a2f25d22..bdb8bd639 100644 --- a/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php +++ b/tests/phpunit/src/Commands/Ssh/SshKeyUploadCommandTest.php @@ -27,33 +27,33 @@ public function providerTestUpload(): array $sshKeysRequestBody = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); return [ [ - // Args. + // Args. [], - // Inputs. + // Inputs. [ - // Choose key. + // Choose key. '0', - // Enter a Cloud Platform label for this SSH key: + // Enter a Cloud Platform label for this SSH key: $sshKeysRequestBody['label'], - // Would you like to wait until Cloud Platform is ready? (yes/no) + // Would you like to wait until Cloud Platform is ready? (yes/no) 'y', - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) 'n', ], // Perms. true, ], [ - // Args. + // Args. [ '--filepath' => 'id_rsa.pub', '--label' => $sshKeysRequestBody['label'], ], // Inputs. [ - // Would you like to wait until Cloud Platform is ready? (yes/no) + // Would you like to wait until Cloud Platform is ready? (yes/no) 'y', - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) 'n', ], // Perms. @@ -87,8 +87,10 @@ public function testUpload(array $args, array $inputs, bool $perms): void $localMachineHelper->getFilesystem()->willReturn($fileSystem); $fileSystem->exists(Argument::type('string'))->willReturn(true); - $localMachineHelper->getLocalFilepath(Argument::containingString('id_rsa'))->willReturn('id_rsa.pub'); - $localMachineHelper->readFile(Argument::type('string'))->willReturn($sshKeysRequestBody['public_key']); + $localMachineHelper->getLocalFilepath(Argument::containingString('id_rsa')) + ->willReturn('id_rsa.pub'); + $localMachineHelper->readFile(Argument::type('string')) + ->willReturn($sshKeysRequestBody['public_key']); if ($perms) { $environmentsResponse = $this->mockEnvironmentsRequest($applicationsResponse); @@ -129,8 +131,10 @@ public function testUploadNode(): void $localMachineHelper->getFilesystem()->willReturn($fileSystem); $fileSystem->exists(Argument::type('string'))->willReturn(true); - $localMachineHelper->getLocalFilepath(Argument::containingString('id_rsa'))->willReturn('id_rsa.pub'); - $localMachineHelper->readFile(Argument::type('string'))->willReturn($sshKeysRequestBody['public_key']); + $localMachineHelper->getLocalFilepath(Argument::containingString('id_rsa')) + ->willReturn('id_rsa.pub'); + $localMachineHelper->readFile(Argument::type('string')) + ->willReturn($sshKeysRequestBody['public_key']); $tamper = function ($responses): void { foreach ($responses as $response) { @@ -143,13 +147,13 @@ public function testUploadNode(): void // Choose a local SSH key to upload to the Cloud Platform. $inputs = [ - // Choose key. + // Choose key. '0', - // Enter a Cloud Platform label for this SSH key: + // Enter a Cloud Platform label for this SSH key: $sshKeysRequestBody['label'], - // Would you like to wait until Cloud Platform is ready? (yes/no) + // Would you like to wait until Cloud Platform is ready? (yes/no) 'y', - // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) + // Would you like Acquia CLI to search for a Cloud application that matches your local git config? (yes/no) 'n', ]; $this->executeCommand([], $inputs); @@ -164,9 +168,9 @@ public function testUploadNode(): void public function testInvalidFilepath(): void { $inputs = [ - // Choose key. + // Choose key. '0', - // Label. + // Label. 'Test', ]; $filepath = Path::join(sys_get_temp_dir(), 'notarealfile'); diff --git a/tests/phpunit/src/Commands/TelemetryCommandTest.php b/tests/phpunit/src/Commands/TelemetryCommandTest.php index 6df390c61..e612ac2f2 100644 --- a/tests/phpunit/src/Commands/TelemetryCommandTest.php +++ b/tests/phpunit/src/Commands/TelemetryCommandTest.php @@ -53,7 +53,7 @@ public function providerTestTelemetryPrompt(): array { return [ [ - // Would you like to share anonymous performance usage and data? + // Would you like to share anonymous performance usage and data? ['n'], 'Ok, no data will be collected and shared with us.', ], diff --git a/tests/phpunit/src/Commands/UpdateCommandTest.php b/tests/phpunit/src/Commands/UpdateCommandTest.php index 5dfad94b4..61412918f 100644 --- a/tests/phpunit/src/Commands/UpdateCommandTest.php +++ b/tests/phpunit/src/Commands/UpdateCommandTest.php @@ -39,7 +39,7 @@ public function testNetworkErrorFailsSilently(): void { $guzzleClient = $this->prophet->prophesize(Client::class); $guzzleClient->get('https://api.github.com/repos/acquia/cli/releases') - ->willThrow(RequestException::class); + ->willThrow(RequestException::class); $this->command->setUpdateClient($guzzleClient->reveal()); $this->application->setVersion('2.8.4.9999s'); $this->executeCommand(); diff --git a/tests/phpunit/src/Commands/WizardTestBase.php b/tests/phpunit/src/Commands/WizardTestBase.php index 34cab7360..36ff823c9 100644 --- a/tests/phpunit/src/Commands/WizardTestBase.php +++ b/tests/phpunit/src/Commands/WizardTestBase.php @@ -54,7 +54,9 @@ public static function getEnvVars(): array protected function runTestCreate(): void { $environmentsResponse = $this->getMockEnvironmentsResponse(); - $this->clientProphecy->request('get', "/applications/{$this::$applicationUuid}/environments")->willReturn($environmentsResponse->_embedded->items)->shouldBeCalled(); + $this->clientProphecy->request('get', "/applications/{$this::$applicationUuid}/environments") + ->willReturn($environmentsResponse->_embedded->items) + ->shouldBeCalled(); $request = $this->getMockRequestBodyFromSpec('/account/ssh-keys'); $body = [ @@ -73,11 +75,14 @@ protected function runTestCreate(): void $fileSystem = $this->prophet->prophesize(Filesystem::class); $this->mockGenerateSshKey($localMachineHelper, $request['public_key']); - $localMachineHelper->getLocalFilepath($this->passphraseFilepath)->willReturn($this->passphraseFilepath); + $localMachineHelper->getLocalFilepath($this->passphraseFilepath) + ->willReturn($this->passphraseFilepath); $fileSystem->remove(Argument::size(2))->shouldBeCalled(); $this->mockAddSshKeyToAgent($localMachineHelper, $fileSystem); $this->mockSshAgentList($localMachineHelper); - $localMachineHelper->getFilesystem()->willReturn($fileSystem->reveal())->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($fileSystem->reveal()) + ->shouldBeCalled(); /** @var SshKeyCreateCommand $sshKeyCreateCommand */ $sshKeyCreateCommand = $this->application->find(SshKeyCreateCommand::getDefaultName()); @@ -94,7 +99,7 @@ protected function runTestCreate(): void // Set properties and execute. $this->executeCommand([], [ - // Would you like to link the project at ... ? + // Would you like to link the project at ... ? 'y', ]); @@ -108,23 +113,23 @@ protected function runTestSshKeyAlreadyUploaded(): void // Make the uploaded key match the created one. $sshKeysResponse->_embedded->items[0]->public_key = $mockRequestArgs['public_key']; $this->clientProphecy->request('get', '/account/ssh-keys') - ->willReturn($sshKeysResponse->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($sshKeysResponse->{'_embedded'}->items) + ->shouldBeCalled(); $this->clientProphecy->request('get', '/account/ssh-keys/' . $sshKeysResponse->_embedded->items[0]->uuid) - ->willReturn($sshKeysResponse->{'_embedded'}->items[0]) - ->shouldBeCalled(); + ->willReturn($sshKeysResponse->{'_embedded'}->items[0]) + ->shouldBeCalled(); $deleteResponse = $this->prophet->prophesize(ResponseInterface::class); $deleteResponse->getStatusCode()->willReturn(202); $this->clientProphecy->makeRequest('delete', '/account/ssh-keys/' . $sshKeysResponse->_embedded->items[0]->uuid) - ->willReturn($deleteResponse->reveal()) - ->shouldBeCalled(); + ->willReturn($deleteResponse->reveal()) + ->shouldBeCalled(); $environmentsResponse = $this->getMockEnvironmentsResponse(); $this->clientProphecy->request('get', "/applications/{$this::$applicationUuid}/environments") - ->willReturn($environmentsResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($environmentsResponse->_embedded->items) + ->shouldBeCalled(); $localMachineHelper = $this->mockLocalMachineHelper(); @@ -145,8 +150,8 @@ protected function runTestSshKeyAlreadyUploaded(): void $fileSystem->remove(Argument::size(2))->shouldBeCalled(); $this->mockAddSshKeyToAgent($localMachineHelper, $fileSystem); $localMachineHelper->getFilesystem() - ->willReturn($fileSystem->reveal()) - ->shouldBeCalled(); + ->willReturn($fileSystem->reveal()) + ->shouldBeCalled(); $this->mockSshAgentList($localMachineHelper); $this->application->find(SshKeyCreateCommand::getDefaultName())->localMachineHelper = $this->command->localMachineHelper; @@ -158,9 +163,9 @@ protected function runTestSshKeyAlreadyUploaded(): void } /** - * @return string[] - * An array of strings to inspect the output for. - */ + * @return string[] + * An array of strings to inspect the output for. + */ protected function getOutputStrings(): array { return [ diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index b38af09d9..a46e9657d 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -18,6 +18,7 @@ class ExceptionListenerTest extends TestBase { private static string $siteAliasHelp = 'environmentId can also be a site alias. E.g. myapp.dev.' . PHP_EOL . 'Run acli remote:aliases:list to see a list of all available aliases.'; + private static string $appAliasHelp = 'The applicationUuid argument must be a valid UUID or unique application alias accessible to your Cloud Platform user.' . PHP_EOL . PHP_EOL . 'An alias consists of an application name optionally prefixed with a hosting realm, e.g. myapp or prod.myapp.' . PHP_EOL . PHP_EOL . 'Run acli remote:aliases:list to see a list of all available aliases.'; /** @@ -28,7 +29,10 @@ public function testHelp(Throwable $error, string|array $helpText): void $exceptionListener = new ExceptionListener(); $commandProphecy = $this->prophet->prophesize(Command::class); $applicationProphecy = $this->prophet->prophesize(Application::class); - $messages1 = ['You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/', 'You can submit a support ticket at https://support-acquia.force.com/s/contactsupport' . PHP_EOL . 'Re-run the command with the -vvv flag and include the full command output in your support ticket.']; + $messages1 = [ + 'You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/', + 'You can submit a support ticket at https://support-acquia.force.com/s/contactsupport' . PHP_EOL . 'Re-run the command with the -vvv flag and include the full command output in your support ticket.', + ]; if (is_array($helpText)) { $messages = array_merge($helpText, $messages1); } else { @@ -36,7 +40,8 @@ public function testHelp(Throwable $error, string|array $helpText): void } $messages[0] = "How to fix it: $messages[0]"; $applicationProphecy->setHelpMessages($messages)->shouldBeCalled(); - $commandProphecy->getApplication()->willReturn($applicationProphecy->reveal()); + $commandProphecy->getApplication() + ->willReturn($applicationProphecy->reveal()); $consoleErrorEvent = new ConsoleErrorEvent($this->input, $this->output, $error, $commandProphecy->reveal()); $exceptionListener->onConsoleError($consoleErrorEvent); $this->prophet->checkPredictions(); @@ -98,15 +103,27 @@ public function providerTestHelp(): array 'Check that you have write access to the directory', ], [ - new ApiErrorException((object) ['error' => '', 'message' => "There are no available Cloud IDEs for this application.\n"]), + new ApiErrorException((object) [ + 'error' => '', + 'message' => "There are no available Cloud IDEs for this application.\n", + ]), 'Delete an existing IDE via acli ide:delete or contact your Account Manager or Acquia Sales to purchase additional IDEs.', ], [ - new ApiErrorException((object) ['error' => '', 'message' => 'This resource requires additional authentication.']), - ['This is likely because you have Federated Authentication required for your organization.', 'Run `acli login` to authenticate via API token and then try again.'], + new ApiErrorException((object) [ + 'error' => '', + 'message' => 'This resource requires additional authentication.', + ]), + [ + 'This is likely because you have Federated Authentication required for your organization.', + 'Run `acli login` to authenticate via API token and then try again.', + ], ], [ - new ApiErrorException((object) ['error' => 'asdf', 'message' => 'fdsa']), + new ApiErrorException((object) [ + 'error' => 'asdf', + 'message' => 'fdsa', + ]), 'You can learn more about Cloud Platform API at https://docs.acquia.com/cloud-platform/develop/api/', ], ]; diff --git a/tests/phpunit/src/Misc/LocalMachineHelperTest.php b/tests/phpunit/src/Misc/LocalMachineHelperTest.php index 18d97bb50..ba6d018a1 100644 --- a/tests/phpunit/src/Misc/LocalMachineHelperTest.php +++ b/tests/phpunit/src/Misc/LocalMachineHelperTest.php @@ -55,7 +55,10 @@ public function testExecuteWithCwd(): void { $this->setupFsFixture(); $localMachineHelper = $this->localMachineHelper; - $process = $localMachineHelper->execute(['ls', '-lash'], null, $this->fixtureDir, false); + $process = $localMachineHelper->execute([ + 'ls', + '-lash', + ], null, $this->fixtureDir, false); $this->assertTrue($process->isSuccessful()); $this->assertStringContainsString('xdebug.ini', $process->getOutput()); } diff --git a/tests/phpunit/src/Misc/TelemetryHelperTest.php b/tests/phpunit/src/Misc/TelemetryHelperTest.php index 7e4c2d57d..785ff3abf 100644 --- a/tests/phpunit/src/Misc/TelemetryHelperTest.php +++ b/tests/phpunit/src/Misc/TelemetryHelperTest.php @@ -63,7 +63,8 @@ public function testEnvironmentProvider(string $provider, array $envVars): void } /** - * Test the getEnvironmentProvider method when no environment provider is detected. + * Test the getEnvironmentProvider method when no environment provider is + * detected. */ public function testGetEnvironmentProviderWithoutAnyEnvSet(): void { diff --git a/tests/phpunit/src/TestBase.php b/tests/phpunit/src/TestBase.php index a51ec15d2..a2bfd0a28 100644 --- a/tests/phpunit/src/TestBase.php +++ b/tests/phpunit/src/TestBase.php @@ -119,9 +119,9 @@ abstract class TestBase extends TestCase /** * Filter an applications response in order to simulate query filters. * - * The CXAPI spec returns two sample applications with identical hosting ids. - * While hosting ids are not guaranteed to be unique, in practice they are - * unique. This renames one of the applications to be unique. + * The CXAPI spec returns two sample applications with identical hosting + * ids. While hosting ids are not guaranteed to be unique, in practice they + * are unique. This renames one of the applications to be unique. * * @see CXAPI-9647 */ @@ -136,7 +136,8 @@ public function filterApplicationsResponse(object $applicationsResponse, int $co } /** - * @todo get rid of this method and use virtual file systems (setupVfsFixture) + * @todo get rid of this method and use virtual file systems + * (setupVfsFixture) */ public function setupFsFixture(): void { @@ -176,9 +177,15 @@ protected function setUp(): void $this->setIo(); $this->vfsRoot = vfsStream::setup(); - $this->projectDir = vfsStream::newDirectory('project')->at($this->vfsRoot)->url(); - $this->sshDir = vfsStream::newDirectory('ssh')->at($this->vfsRoot)->url(); - $this->dataDir = vfsStream::newDirectory('.acquia')->at($this->vfsRoot)->url(); + $this->projectDir = vfsStream::newDirectory('project') + ->at($this->vfsRoot) + ->url(); + $this->sshDir = vfsStream::newDirectory('ssh') + ->at($this->vfsRoot) + ->url(); + $this->dataDir = vfsStream::newDirectory('.acquia') + ->at($this->vfsRoot) + ->url(); $this->cloudConfigFilepath = Path::join($this->dataDir, 'cloud_api.conf'); $this->acliConfigFilename = '.acquia-cli.yml'; $this->acliConfigFilepath = Path::join($this->projectDir, $this->acliConfigFilename); @@ -326,10 +333,10 @@ protected function getPathMethodCodeFromSpec(string $operationId): array /** * Build and return a command with common dependencies. * - * All commands inherit from a common base and use the same constructor with a - * bunch of dependencies injected. It would be tedious for every command test - * to inject every dependency as part of createCommand(). They can use this - * instead. + * All commands inherit from a common base and use the same constructor + * with a bunch of dependencies injected. It would be tedious for every + * command test to inject every dependency as part of createCommand(). They + * can use this instead. */ protected function injectCommand(string $commandName): Command { @@ -382,7 +389,7 @@ private function isApiSpecCacheValid(PhpArrayAdapter $cache, mixed $cacheKey, st $apiSpecChecksumItem = $cache->getItem($cacheKey . '.checksum'); // If there's an invalid entry OR there's no entry, return false. return !(!$apiSpecChecksumItem->isHit() || ($apiSpecChecksumItem->isHit() - && $apiSpecChecksumItem->get() !== $acquiaCloudSpecFileChecksum)); + && $apiSpecChecksumItem->get() !== $acquiaCloudSpecFileChecksum)); } private function saveApiSpecCacheItems( @@ -446,9 +453,11 @@ protected function createMockAcliConfigFile(string $cloudAppUuid): void } /** - * This is the preferred generic way of mocking requests and responses. We still maintain a lot of boilerplate mocking methods for legacy reasons. + * This is the preferred generic way of mocking requests and responses. We + * still maintain a lot of boilerplate mocking methods for legacy reasons. * - * Auto-completion and return type inferencing is provided by .phpstorm.meta.php. + * Auto-completion and return type inferencing is provided by + * .phpstorm.meta.php. */ protected function mockRequest(string $operationId, string|array|null $params = null, ?array $body = null, ?string $exampleResponse = null, Closure $tamper = null): object|array { @@ -457,7 +466,11 @@ protected function mockRequest(string $operationId, string|array|null $params = } elseif (is_null($params)) { $params = []; } - [$path, $method, $code] = $this->getPathMethodCodeFromSpec($operationId); + [ + $path, + $method, + $code, + ] = $this->getPathMethodCodeFromSpec($operationId); if (count($params) !== substr_count($path, '{')) { throw new RuntimeException('Invalid number of parameters'); } @@ -478,13 +491,14 @@ protected function mockRequest(string $operationId, string|array|null $params = $path = preg_replace('/\{\w*}/', $param, $path, 1); } $this->clientProphecy->request($method, $path, $body) - ->willReturn($response) - ->shouldBeCalled(); + ->willReturn($response) + ->shouldBeCalled(); return $response; } /** - * @param int $count The number of applications to return. Use this to simulate query filters. + * @param int $count The number of applications to return. Use this to + * simulate query filters. */ public function mockApplicationsRequest(int $count = 2, bool $unique = true): object { @@ -496,8 +510,8 @@ public function mockApplicationsRequest(int $count = 2, bool $unique = true): ob ); $applicationsResponse = $this->filterApplicationsResponse($applicationsResponse, $count, $unique); $this->clientProphecy->request('get', '/applications') - ->willReturn($applicationsResponse->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($applicationsResponse->{'_embedded'}->items) + ->shouldBeCalled(); return $applicationsResponse; } @@ -508,7 +522,7 @@ public function mockUnauthorizedRequest(): void 'error_description' => 'Client credentials were not found in the headers or body', ]; $this->clientProphecy->request('get', Argument::type('string')) - ->willThrow(new IdentityProviderException($response['error'], 0, $response)); + ->willThrow(new IdentityProviderException($response['error'], 0, $response)); } public function mockApiError(): void @@ -518,7 +532,7 @@ public function mockApiError(): void 'message' => 'some error', ]; $this->clientProphecy->request('get', Argument::type('string')) - ->willThrow(new ApiErrorException($response, $response->message)); + ->willThrow(new ApiErrorException($response, $response->message)); } public function mockNoAvailableIdes(): void @@ -528,7 +542,7 @@ public function mockNoAvailableIdes(): void 'message' => "There are no available Cloud IDEs for this application.\n", ]; $this->clientProphecy->request('get', Argument::type('string')) - ->willThrow(new ApiErrorException($response, $response->message)); + ->willThrow(new ApiErrorException($response, $response->message)); } protected function mockApplicationRequest(): object @@ -543,8 +557,8 @@ protected function mockApplicationRequest(): object 'get', '/applications/' . $applicationsResponse->{'_embedded'}->items[0]->uuid ) - ->willReturn($applicationResponse) - ->shouldBeCalled(); + ->willReturn($applicationResponse) + ->shouldBeCalled(); return $applicationResponse; } @@ -572,8 +586,8 @@ protected function mockPermissionsRequest(mixed $applicationResponse, mixed $per 'get', '/applications/' . $applicationResponse->uuid . '/permissions' ) - ->willReturn($permissionsResponse->_embedded->items) - ->shouldBeCalled(); + ->willReturn($permissionsResponse->_embedded->items) + ->shouldBeCalled(); return $permissionsResponse; } @@ -586,8 +600,8 @@ public function mockEnvironmentsRequest( 'get', "/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments" ) - ->willReturn($response->_embedded->items) - ->shouldBeCalled(); + ->willReturn($response->_embedded->items) + ->shouldBeCalled(); return $response; } @@ -623,8 +637,8 @@ protected function mockListSshKeysRequestWithIdeKey(string $ideLabel, string $id $mockBody = $this->getMockResponseFromSpec('/account/ssh-keys', 'get', '200'); $mockBody->{'_embedded'}->items[0]->label = preg_replace('/\W/', '', 'IDE_' . $ideLabel . '_' . $ideUuid); $this->clientProphecy->request('get', '/account/ssh-keys') - ->willReturn($mockBody->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($mockBody->{'_embedded'}->items) + ->shouldBeCalled(); return $mockBody; } @@ -635,23 +649,28 @@ protected function mockGenerateSshKey(ObjectProphecy|LocalMachineHelper $localMa $process = $this->prophet->prophesize(Process::class); $process->isSuccessful()->willReturn(true); $process->getOutput()->willReturn($keyContents); - $localMachineHelper->checkRequiredBinariesExist(["ssh-keygen"])->shouldBeCalled(); + $localMachineHelper->checkRequiredBinariesExist(["ssh-keygen"]) + ->shouldBeCalled(); $localMachineHelper->execute(Argument::withEntry(0, 'ssh-keygen'), null, null, false) - ->willReturn($process->reveal()) - ->shouldBeCalled(); + ->willReturn($process->reveal()) + ->shouldBeCalled(); $localMachineHelper->readFile($publicKeyPath)->willReturn($keyContents); - $localMachineHelper->readFile(Argument::containingString('id_rsa'))->willReturn($keyContents); + $localMachineHelper->readFile(Argument::containingString('id_rsa')) + ->willReturn($keyContents); } protected function mockAddSshKeyToAgent(mixed $localMachineHelper, mixed $fileSystem): void { $process = $this->prophet->prophesize(Process::class); $process->isSuccessful()->willReturn(true); - $localMachineHelper->executeFromCmd(Argument::containingString('SSH_PASS'), null, null, false)->willReturn($process->reveal()); - $fileSystem->tempnam(Argument::type('string'), 'acli')->willReturn('something'); + $localMachineHelper->executeFromCmd(Argument::containingString('SSH_PASS'), null, null, false) + ->willReturn($process->reveal()); + $fileSystem->tempnam(Argument::type('string'), 'acli') + ->willReturn('something'); $fileSystem->chmod('something', 493)->shouldBeCalled(); $fileSystem->remove('something')->shouldBeCalled(); - $localMachineHelper->writeFile('something', Argument::type('string'))->shouldBeCalled(); + $localMachineHelper->writeFile('something', Argument::type('string')) + ->shouldBeCalled(); } protected function mockSshAgentList(ObjectProphecy|LocalMachineHelper $localMachineHelper, bool $success = false): void @@ -661,7 +680,7 @@ protected function mockSshAgentList(ObjectProphecy|LocalMachineHelper $localMach $process->getExitCode()->willReturn($success ? 0 : 1); $process->getOutput()->willReturn('thekey!'); $localMachineHelper->getLocalFilepath($this->passphraseFilepath) - ->willReturn('/tmp/.passphrase'); + ->willReturn('/tmp/.passphrase'); $localMachineHelper->execute([ 'ssh-add', '-L', @@ -684,8 +703,8 @@ protected function mockListSshKeyRequestWithUploadedKey( $newItem = array_merge((array) $mockBody->_embedded->items[2], $mockRequestArgs); $mockBody->_embedded->items[3] = (object) $newItem; $this->clientProphecy->request('get', '/account/ssh-keys') - ->willReturn($mockBody->{'_embedded'}->items) - ->shouldBeCalled(); + ->willReturn($mockBody->{'_embedded'}->items) + ->shouldBeCalled(); } protected function mockStartPhp(ObjectProphecy|LocalMachineHelper $localMachineHelper): ObjectProphecy @@ -732,7 +751,9 @@ protected function mockRestartPhp(ObjectProphecy|LocalMachineHelper $localMachin */ protected function mockGetFilesystem(ObjectProphecy|LocalMachineHelper $localMachineHelper): ObjectProphecy|Filesystem { - $localMachineHelper->getFilesystem()->willReturn($this->fs)->shouldBeCalled(); + $localMachineHelper->getFilesystem() + ->willReturn($this->fs) + ->shouldBeCalled(); return $this->fs; } @@ -761,7 +782,7 @@ public function mockGuzzleClientForUpdate(array $releases): ObjectProphecy $response->getBody()->willReturn($stream->reveal()); $guzzleClient = $this->prophet->prophesize(\GuzzleHttp\Client::class); $guzzleClient->request('GET', Argument::containingString('https://api.github.com/repos'), Argument::type('array')) - ->willReturn($response->reveal()); + ->willReturn($response->reveal()); $stream = $this->prophet->prophesize(StreamInterface::class); $pharContents = file_get_contents(Path::join($this->fixtureDir, 'test.phar')); @@ -784,9 +805,9 @@ protected function setClientProphecies(): void $this->clientProphecy->addOption('debug', Argument::type(OutputInterface::class)); $this->clientServiceProphecy = $this->prophet->prophesize(ClientService::class); $this->clientServiceProphecy->getClient() - ->willReturn($this->clientProphecy->reveal()); + ->willReturn($this->clientProphecy->reveal()); $this->clientServiceProphecy->isMachineAuthenticated() - ->willReturn(true); + ->willReturn(true); } protected function createDataStores(): void From fded214ede6392de0f267f3ac3fa78872ffef6a1 Mon Sep 17 00:00:00 2001 From: PrakharJainS3 <166108108+PrakharJainS3@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:36:42 +0530 Subject: [PATCH 3/4] GL-2753 : CS Wizard updated node version select values (#1767) * GL-2753 : CS Wizard updated node version select values * undo style changes * kill mutant --------- Co-authored-by: Dane Powell --- .../CodeStudio/CodeStudioWizardCommand.php | 6 +-- .../CodeStudioWizardCommandTest.php | 38 +++++++++---------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/Command/CodeStudio/CodeStudioWizardCommand.php b/src/Command/CodeStudio/CodeStudioWizardCommand.php index e49199bbd..8de74f368 100644 --- a/src/Command/CodeStudio/CodeStudioWizardCommand.php +++ b/src/Command/CodeStudio/CodeStudioWizardCommand.php @@ -62,10 +62,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int break; case "Node_project": $nodeVersions = [ - 'NODE_version_18.17.1' => "18.17.1", - 'NODE_version_20.5.1' => "20.5.1", + 'NODE_version_18' => "18", + 'NODE_version_20' => "20", ]; - $project = $this->io->choice('Select a NODE version', array_values($nodeVersions), "18.17.1"); + $project = $this->io->choice('Select a NODE version', array_values($nodeVersions), "20"); $project = array_search($project, $nodeVersions, true); $nodeVersion = $nodeVersions[$project]; break; diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index a2d4b6993..af42d76f9 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -65,6 +65,8 @@ public function providerTestCommand(): array [$this->getMockedGitLabProject($this->gitLabProjectId)], // Inputs. [ + 0, + 0, // Do you want to continue? 'y', // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: @@ -84,6 +86,9 @@ public function providerTestCommand(): array ], // Inputs. [ + 0, + 0, + 'n', // Found multiple projects that could match the Sample application 1 application. Choose which one to configure. '0', // Do you want to continue? @@ -102,6 +107,8 @@ public function providerTestCommand(): array [], // Inputs. [ + 0, + 0, // 'Would you like to create a new Code Studio project? 'y', // Select a project type Drupal_project. @@ -124,8 +131,6 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Select a project type Drupal_project. '0', // Select PHP version 8.2. @@ -146,11 +151,9 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Select a project type Node_project. '1', - // Select NODE version 18.17.1. + // Select NODE version 18. '0', // Do you want to continue? 'y', @@ -168,11 +171,9 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Select a project type Node_project. '1', - // Select NODE version 20.5.1. + // Select NODE version 20. '1', // Do you want to continue? 'y', @@ -190,8 +191,10 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'n', + 0, + 0, + 'y', + 'y', // Choose project. '0', // Do you want to continue? @@ -208,8 +211,6 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Enter Cloud Key. $this->key, // Enter Cloud secret,. @@ -229,15 +230,13 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Enter Cloud Key. $this->key, // Enter Cloud secret,. $this->secret, // Select a project type Node_project. '1', - // Select NODE version 18.17.1. + // Select NODE version 18. '0', // Do you want to continue? 'y', @@ -250,8 +249,6 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Enter Cloud Key. $this->key, // Enter Cloud secret,. @@ -271,15 +268,13 @@ public function providerTestCommand(): array [], // Inputs. [ - // 'Would you like to create a new Code Studio project? - 'y', // Enter Cloud Key. $this->key, // Enter Cloud secret,. $this->secret, // Select a project type Node_project. '1', - // Select NODE version 20.5.1. + // Select NODE version 20. '1', // Do you want to continue? 'y', @@ -332,7 +327,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a )->shouldBeCalled(); $this->mockGitLabVariables($this->gitLabProjectId, $projects); - if ($inputs[0] === 'y' && ($inputs[1] === '1' || (array_key_exists(3, $inputs) && $inputs[3] === '1'))) { + if (($inputs[0] === '1' || (array_key_exists(2, $inputs) && $inputs[2] === '1'))) { $parameters = [ 'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template', ]; @@ -387,6 +382,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a foreach ($output_strings as $output_string) { self::assertStringContainsString($output_string, $output); } + self::assertStringNotContainsString('[ERROR]', $output); // Assertions. $this->assertEquals(0, $this->getStatusCode()); From 6fbaaa3e913de35fdc64b84e1a56762d78f89014 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Thu, 11 Jul 2024 13:11:18 -0700 Subject: [PATCH 4/4] update coding standards --- composer.json | 2 +- composer.lock | 38 +++++++++++++++++++------------------- phpcs.xml.dist | 3 --- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index bc39fe6fc..8a08cd3b9 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "zumba/amplitude-php": "^1.0.4" }, "require-dev": { - "acquia/coding-standards": "^3", + "acquia/coding-standards": "^3.0.1", "brianium/paratest": "^6.6", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "dominikb/composer-license-checker": "^2.4", diff --git a/composer.lock b/composer.lock index 48d7983f2..7283ef564 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "94d7cb39421243e4ac74c5f67b895fc3", + "content-hash": "cf656c7a733183495270ef1b8d92ade8", "packages": [ { "name": "acquia/drupal-environment-detector", @@ -6438,16 +6438,16 @@ }, { "name": "zumba/amplitude-php", - "version": "1.0.7", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/zumba/amplitude-php.git", - "reference": "b1fd002f562a1d073c40d2f1d4b9a1f59b857083" + "reference": "5288ede9c4bcee3dd4c6e6bb928fc32d489ffddd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zumba/amplitude-php/zipball/b1fd002f562a1d073c40d2f1d4b9a1f59b857083", - "reference": "b1fd002f562a1d073c40d2f1d4b9a1f59b857083", + "url": "https://api.github.com/repos/zumba/amplitude-php/zipball/5288ede9c4bcee3dd4c6e6bb928fc32d489ffddd", + "reference": "5288ede9c4bcee3dd4c6e6bb928fc32d489ffddd", "shasum": "" }, "require": { @@ -6493,24 +6493,24 @@ ], "support": { "issues": "https://github.com/zumba/amplitude-php/issues", - "source": "https://github.com/zumba/amplitude-php/tree/1.0.7" + "source": "https://github.com/zumba/amplitude-php/tree/1.0.8" }, - "time": "2023-03-08T16:59:22+00:00" + "time": "2024-07-11T14:35:33+00:00" } ], "packages-dev": [ { "name": "acquia/coding-standards", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/acquia/coding-standards-php.git", - "reference": "ca05888f8dd2e2378f7efc18a0096d41b1a5a66e" + "reference": "7315583494b81cbcbd8817d7e00dd8f4fba34b88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/acquia/coding-standards-php/zipball/ca05888f8dd2e2378f7efc18a0096d41b1a5a66e", - "reference": "ca05888f8dd2e2378f7efc18a0096d41b1a5a66e", + "url": "https://api.github.com/repos/acquia/coding-standards-php/zipball/7315583494b81cbcbd8817d7e00dd8f4fba34b88", + "reference": "7315583494b81cbcbd8817d7e00dd8f4fba34b88", "shasum": "" }, "require": { @@ -6556,7 +6556,7 @@ "issues": "https://github.com/acquia/coding-standards/issues", "source": "https://github.com/acquia/coding-standards" }, - "time": "2024-07-10T21:13:42+00:00" + "time": "2024-07-11T20:08:50+00:00" }, { "name": "amphp/amp", @@ -12355,23 +12355,23 @@ }, { "name": "seld/jsonlint", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259" + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/9bb7db07b5d66d90f6ebf542f09fc67d800e5259", - "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2", "shasum": "" }, "require": { "php": "^5.3 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1.5", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" }, "bin": [ @@ -12403,7 +12403,7 @@ ], "support": { "issues": "https://github.com/Seldaek/jsonlint/issues", - "source": "https://github.com/Seldaek/jsonlint/tree/1.10.2" + "source": "https://github.com/Seldaek/jsonlint/tree/1.11.0" }, "funding": [ { @@ -12415,7 +12415,7 @@ "type": "tidelift" } ], - "time": "2024-02-07T12:57:50+00:00" + "time": "2024-07-11T14:55:45+00:00" }, { "name": "seld/phar-utils", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 11def6e88..03df4eece 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -26,9 +26,6 @@ - - -