diff --git a/composer.lock b/composer.lock index 5ca713e16..cb9779e4c 100644 --- a/composer.lock +++ b/composer.lock @@ -4435,7 +4435,7 @@ }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", @@ -4491,7 +4491,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" }, "funding": [ { @@ -6698,16 +6698,16 @@ }, { "name": "amphp/byte-stream", - "version": "v2.0.2", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb" + "reference": "0a4b0e80dad92c75e6131f8ad253919211540338" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb", - "reference": "408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/0a4b0e80dad92c75e6131f8ad253919211540338", + "reference": "0a4b0e80dad92c75e6131f8ad253919211540338", "shasum": "" }, "require": { @@ -6761,7 +6761,7 @@ ], "support": { "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/v2.0.2" + "source": "https://github.com/amphp/byte-stream/tree/v2.1.0" }, "funding": [ { @@ -6769,7 +6769,7 @@ "type": "github" } ], - "time": "2023-09-01T04:41:26+00:00" + "time": "2023-11-19T14:34:16+00:00" }, { "name": "amphp/cache", @@ -6838,16 +6838,16 @@ }, { "name": "amphp/dns", - "version": "v2.0.1", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/amphp/dns.git", - "reference": "e42876aa8306c754abd1b3e71a44e13066909fd1" + "reference": "c3b518f321f26e786554480de580f06b9f34d1cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/dns/zipball/e42876aa8306c754abd1b3e71a44e13066909fd1", - "reference": "e42876aa8306c754abd1b3e71a44e13066909fd1", + "url": "https://api.github.com/repos/amphp/dns/zipball/c3b518f321f26e786554480de580f06b9f34d1cd", + "reference": "c3b518f321f26e786554480de580f06b9f34d1cd", "shasum": "" }, "require": { @@ -6914,7 +6914,7 @@ ], "support": { "issues": "https://github.com/amphp/dns/issues", - "source": "https://github.com/amphp/dns/tree/v2.0.1" + "source": "https://github.com/amphp/dns/tree/v2.1.0" }, "funding": [ { @@ -6922,20 +6922,20 @@ "type": "github" } ], - "time": "2023-01-21T16:00:09+00:00" + "time": "2023-11-18T15:49:57+00:00" }, { "name": "amphp/parallel", - "version": "v2.2.2", + "version": "v2.2.3", "source": { "type": "git", "url": "https://github.com/amphp/parallel.git", - "reference": "f54bb4090670397544f74e14a1e650bf2cfd853b" + "reference": "223c47cfa57dc8166d058c072c47fe650d6b5b1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/parallel/zipball/f54bb4090670397544f74e14a1e650bf2cfd853b", - "reference": "f54bb4090670397544f74e14a1e650bf2cfd853b", + "url": "https://api.github.com/repos/amphp/parallel/zipball/223c47cfa57dc8166d058c072c47fe650d6b5b1d", + "reference": "223c47cfa57dc8166d058c072c47fe650d6b5b1d", "shasum": "" }, "require": { @@ -6997,7 +6997,7 @@ ], "support": { "issues": "https://github.com/amphp/parallel/issues", - "source": "https://github.com/amphp/parallel/tree/v2.2.2" + "source": "https://github.com/amphp/parallel/tree/v2.2.3" }, "funding": [ { @@ -7005,7 +7005,7 @@ "type": "github" } ], - "time": "2023-08-30T17:43:42+00:00" + "time": "2023-11-25T00:18:59+00:00" }, { "name": "amphp/parser", @@ -9267,16 +9267,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.2", + "version": "v1.3.3", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c" + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", "shasum": "" }, "require": { @@ -9323,7 +9323,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-10-17T13:38:16+00:00" + "time": "2023-11-08T14:08:06+00:00" }, { "name": "league/uri", @@ -10337,46 +10337,46 @@ }, { "name": "phpro/grumphp", - "version": "v2.2.0", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/phpro/grumphp.git", - "reference": "afaf2ecd1def53403dd4989465cab62557c9bd22" + "reference": "1221db808687e0632930b9034badd3c1c286338f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpro/grumphp/zipball/afaf2ecd1def53403dd4989465cab62557c9bd22", - "reference": "afaf2ecd1def53403dd4989465cab62557c9bd22", + "url": "https://api.github.com/repos/phpro/grumphp/zipball/1221db808687e0632930b9034badd3c1c286338f", + "reference": "1221db808687e0632930b9034badd3c1c286338f", "shasum": "" }, "require": { "amphp/amp": "^3.0", "amphp/parallel": "^2.1", - "composer-plugin-api": "~2.0", + "composer-plugin-api": "^2.0", "doctrine/collections": "^1.6.8 || ^2.0", "ext-json": "*", "gitonomy/gitlib": "^1.3", "laravel/serializable-closure": "^1.1", "monolog/monolog": "^2.0 || ^3.0", "ondram/ci-detector": "^4.0", - "php": "^8.1", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "psr/container": "^1.1 || ^2.0", - "seld/jsonlint": "~1.8", - "symfony/config": "~5.4 || ~6.0", - "symfony/console": "~5.4 || ~6.0", - "symfony/dependency-injection": "~5.4 || ~6.0", - "symfony/dotenv": "~5.4 || ~6.0", - "symfony/event-dispatcher": "~5.4 || ~6.0", - "symfony/filesystem": "~5.4 || ~6.0", - "symfony/finder": "~5.4 || ~6.0", - "symfony/options-resolver": "~5.4 || ~6.0", - "symfony/process": "~5.4 || ~6.0", - "symfony/yaml": "~5.4 || ~6.0" + "seld/jsonlint": "^1.8", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/dotenv": "^5.4 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "brianium/paratest": "^6.4", "composer/composer": "^2.2.6", - "nikic/php-parser": "~4.13", + "nikic/php-parser": "^4.13", "php-parallel-lint/php-parallel-lint": "^1.3", "phpspec/phpspec": "^7.2", "phpspec/prophecy-phpunit": "^2.0", @@ -10447,9 +10447,9 @@ "description": "A composer plugin that enables source code quality checks.", "support": { "issues": "https://github.com/phpro/grumphp/issues", - "source": "https://github.com/phpro/grumphp/tree/v2.2.0" + "source": "https://github.com/phpro/grumphp/tree/v2.3.0" }, - "time": "2023-10-27T05:19:45+00:00" + "time": "2023-11-24T06:56:17+00:00" }, { "name": "phpspec/prophecy", @@ -10664,16 +10664,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.43", + "version": "1.10.44", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "2c4129f6ca8c7cfa870098884b8869b410a5a361" + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2c4129f6ca8c7cfa870098884b8869b410a5a361", - "reference": "2c4129f6ca8c7cfa870098884b8869b410a5a361", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bf84367c53a23f759513985c54ffe0d0c249825b", + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b", "shasum": "" }, "require": { @@ -10722,7 +10722,7 @@ "type": "tidelift" } ], - "time": "2023-11-19T19:55:25+00:00" + "time": "2023-11-21T16:30:46+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -11247,16 +11247,16 @@ }, { "name": "revolt/event-loop", - "version": "v1.0.4", + "version": "v1.0.5", "source": { "type": "git", "url": "https://github.com/revoltphp/event-loop.git", - "reference": "40292c18e53d9a1b7e6c807f4fda5908552e1ba5" + "reference": "fce6063869513de56f639aa522b2ef2fedbf8d73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/revoltphp/event-loop/zipball/40292c18e53d9a1b7e6c807f4fda5908552e1ba5", - "reference": "40292c18e53d9a1b7e6c807f4fda5908552e1ba5", + "url": "https://api.github.com/repos/revoltphp/event-loop/zipball/fce6063869513de56f639aa522b2ef2fedbf8d73", + "reference": "fce6063869513de56f639aa522b2ef2fedbf8d73", "shasum": "" }, "require": { @@ -11266,7 +11266,7 @@ "ext-json": "*", "jetbrains/phpstorm-stubs": "^2019.3", "phpunit/phpunit": "^9", - "psalm/phar": "^4.7" + "psalm/phar": "^5.15" }, "type": "library", "extra": { @@ -11313,9 +11313,9 @@ ], "support": { "issues": "https://github.com/revoltphp/event-loop/issues", - "source": "https://github.com/revoltphp/event-loop/tree/v1.0.4" + "source": "https://github.com/revoltphp/event-loop/tree/v1.0.5" }, - "time": "2023-10-22T03:19:00+00:00" + "time": "2023-11-19T14:45:35+00:00" }, { "name": "sanmai/later", @@ -13105,26 +13105,27 @@ }, { "name": "twig/twig", - "version": "v3.7.1", + "version": "v3.8.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554" + "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", "shasum": "" }, "require": { "php": ">=7.2.5", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php80": "^1.22" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3" + "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" }, "type": "library", "autoload": { @@ -13160,7 +13161,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.7.1" + "source": "https://github.com/twigphp/Twig/tree/v3.8.0" }, "funding": [ { @@ -13172,7 +13173,7 @@ "type": "tidelift" } ], - "time": "2023-08-28T11:09:02+00:00" + "time": "2023-11-21T18:54:41+00:00" }, { "name": "webmozart/assert", diff --git a/src/Command/Pull/PullCommandBase.php b/src/Command/Pull/PullCommandBase.php index ef594ef6e..95e03f300 100644 --- a/src/Command/Pull/PullCommandBase.php +++ b/src/Command/Pull/PullCommandBase.php @@ -410,7 +410,7 @@ private function importDatabaseDump(string $localDumpFilepath, string $dbHost, s } else { $this->io->warning('Install `pv` to see progress bar'); - $command = "gunzip $localDumpFilepath | MYSQL_PWD=$dbPassword mysql --host=$dbHost --user=$dbUser $dbName"; + $command = "gunzip -c $localDumpFilepath | MYSQL_PWD=$dbPassword mysql --host=$dbHost --user=$dbUser $dbName"; } $process = $this->localMachineHelper->executeFromCmd($command, $outputCallback, NULL, ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL)); diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index 0983d2023..4c20c7a41 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -358,11 +358,12 @@ protected function mockCreateMySqlDumpOnLocal(ObjectProphecy $localMachineHelper } protected function mockExecutePvExists( - ObjectProphecy $localMachineHelper + ObjectProphecy $localMachineHelper, + bool $pvExists = TRUE ): void { $localMachineHelper ->commandExists('pv') - ->willReturn(TRUE) + ->willReturn($pvExists) ->shouldBeCalled(); } diff --git a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php index 9eeed79d3..9dffbf465 100644 --- a/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php +++ b/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; /** * @property \Acquia\Cli\Command\Pull\PullDatabaseCommand $command @@ -69,6 +70,15 @@ public function testPullDatabasesLocalConnectionFailure(): void { ], $inputs); } + public function testPullDatabaseNoPv(): void { + $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, 0, TRUE, FALSE); + $inputs = $this->getInputs(); + + $this->executeCommand(['--no-scripts' => TRUE], $inputs); + $output = $this->getDisplay(); + $this->assertStringContainsString(' [WARNING] Install `pv` to see progress bar', $output); + } + public function testPullMultipleDatabases(): void { $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE); $inputs = [ @@ -177,7 +187,7 @@ public function testPullDatabaseWithMySqlImportError(): void { /** * @dataProvider providerTestPullDatabaseWithInvalidSslCertificate */ - public function testPullDatabaseWithInvalidSslCertificate(mixed $errorCode): void { + public function testPullDatabaseWithInvalidSslCertificate(int $errorCode): void { $this->setupPullDatabase(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, $errorCode); $inputs = $this->getInputs(); @@ -187,7 +197,7 @@ public function testPullDatabaseWithInvalidSslCertificate(mixed $errorCode): voi $this->assertStringContainsString('Trying alternative host other.example.com', $output); } - protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mysqlDropSuccessful, bool $mysqlCreateSuccessful, bool $mysqlImportSuccessful, bool $mockIdeFs = FALSE, bool $onDemand = FALSE, bool $mockGetAcsfSites = TRUE, bool $multidb = FALSE, int $curlCode = 0, bool $existingBackups = TRUE): void { + protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mysqlDropSuccessful, bool $mysqlCreateSuccessful, bool $mysqlImportSuccessful, bool $mockIdeFs = FALSE, bool $onDemand = FALSE, bool $mockGetAcsfSites = TRUE, bool $multidb = FALSE, int $curlCode = 0, bool $existingBackups = TRUE, bool $pvExists = TRUE): void { $applicationsResponse = $this->mockApplicationsRequest(); $this->mockApplicationRequest(); $environmentsResponse = $this->mockAcsfEnvironmentsRequest($applicationsResponse); @@ -231,8 +241,10 @@ protected function setupPullDatabase(bool $mysqlConnectSuccessful, bool $mysqlDr // Database. $this->mockExecuteMySqlDropDb($localMachineHelper, $mysqlDropSuccessful); $this->mockExecuteMySqlCreateDb($localMachineHelper, $mysqlCreateSuccessful); - $this->mockExecuteMySqlImport($localMachineHelper, $mysqlImportSuccessful); - + $this->mockExecuteMySqlImport($localMachineHelper, $mysqlImportSuccessful, $pvExists); + if ($multidb) { + $this->mockExecuteMySqlImport($localMachineHelper, $mysqlImportSuccessful, $pvExists, 'profserv2', 'profserv2dev', 'drupal'); + } $this->command->localMachineHelper = $localMachineHelper->reveal(); $this->command->sshHelper = $sshHelper->reveal(); } @@ -291,14 +303,20 @@ protected function mockExecuteMySqlCreateDb( protected function mockExecuteMySqlImport( ObjectProphecy $localMachineHelper, - bool $success + bool $success, + bool $pvExists, + string $dbName = 'jxr5000596dev', + string $dbMachineName = 'db554675', + string $localDbName = 'jxr5000596dev' ): void { $localMachineHelper->checkRequiredBinariesExist(['gunzip', 'mysql'])->shouldBeCalled(); - $this->mockExecutePvExists($localMachineHelper); + $this->mockExecutePvExists($localMachineHelper, $pvExists); $process = $this->mockProcess($success); + $filePath = Path::join(sys_get_temp_dir(), "dev-$dbName-$dbMachineName-2012-05-15T12:00:00Z.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(Argument::type('string'), Argument::type('callable'), + ->executeFromCmd($command, Argument::type('callable'), NULL, TRUE, NULL) ->willReturn($process->reveal()) ->shouldBeCalled();