From b94a3ae9a89fabb1940938b7400217fe072effd6 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Fri, 19 Jul 2024 08:39:39 -0700 Subject: [PATCH] add test case --- tests/phpunit/src/CommandTestBase.php | 8 ++++++-- .../src/Commands/Push/PushDatabaseCommandTest.php | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index 610022ebc..c96fb653c 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -414,13 +414,17 @@ protected function mockNotificationResponseFromObject(object $responseWithNotifi return $this->mockRequest('getNotificationByUuid', $uuid); } - protected function mockCreateMySqlDumpOnLocal(ObjectProphecy $localMachineHelper, bool $printOutput = true): void + protected function mockCreateMySqlDumpOnLocal(ObjectProphecy $localMachineHelper, bool $printOutput = true, bool $pv = true): void { $localMachineHelper->checkRequiredBinariesExist(["mysqldump", "gzip"]) ->shouldBeCalled(); $process = $this->mockProcess(); $process->getOutput()->willReturn(''); - $command = 'bash -c "set -o pipefail; MYSQL_PWD=drupal mysqldump --host=localhost --user=drupal drupal | pv --rate --bytes | gzip -9 > ' . sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz"'; + if ($pv) { + $command = 'bash -c "set -o pipefail; MYSQL_PWD=drupal mysqldump --host=localhost --user=drupal drupal | pv --rate --bytes | gzip -9 > ' . sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz"'; + } else { + $command = 'bash -c "set -o pipefail; MYSQL_PWD=drupal mysqldump --host=localhost --user=drupal drupal | gzip -9 > ' . sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz"'; + } $localMachineHelper->executeFromCmd($command, Argument::type('callable'), null, $printOutput) ->willReturn($process->reveal()) ->shouldBeCalled(); diff --git a/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php b/tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php index 54e1c4c4d..522431228 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, false], + [OutputInterface::VERBOSITY_VERY_VERBOSE, true, true], ]; } @@ -51,7 +51,7 @@ public function setUp(): void /** * @dataProvider providerTestPushDatabase */ - public function testPushDatabase(int $verbosity, bool $printOutput): void + public function testPushDatabase(int $verbosity, bool $printOutput, bool $pv): void { $applications = $this->mockRequest('getApplications'); $application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid); @@ -72,8 +72,8 @@ public function testPushDatabase(int $verbosity, bool $printOutput): void $this->mockGetAcsfSitesLMH($localMachineHelper); // Database. - $this->mockExecutePvExists($localMachineHelper); - $this->mockCreateMySqlDumpOnLocal($localMachineHelper, $printOutput); + $this->mockExecutePvExists($localMachineHelper, $pv); + $this->mockCreateMySqlDumpOnLocal($localMachineHelper, $printOutput, $pv); $this->mockUploadDatabaseDump($localMachineHelper, $process, $printOutput); $this->mockImportDatabaseDumpOnRemote($localMachineHelper, $process, $printOutput);