Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Jul 19, 2024
1 parent b483fc7 commit b94a3ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions tests/phpunit/src/CommandTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/src/Commands/Push/PushDatabaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
];
}

Expand All @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit b94a3ae

Please sign in to comment.