CLI-1210: Drop tables instead of database #1998
Annotations
10 warnings
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L55
Escaped Mutant for Mutator "UnwrapTrim":
--- Original
+++ New
@@ @@
private function listTables(string $out) : array
{
$tables = [];
- if ($out = trim($out)) {
+ if ($out = $out) {
$tables = explode(PHP_EOL, $out);
}
return $tables;
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L58
Escaped Mutant for Mutator "ArrayOneItem":
--- Original
+++ New
@@ @@
if ($out = trim($out)) {
$tables = explode(PHP_EOL, $out);
}
- return $tables;
+ return count($tables) > 1 ? array_slice($tables, 0, 1, true) : $tables;
}
/**
* @see https://github.com/drush-ops/drush/blob/c21a5a24a295cc0513bfdecead6f87f1a2cf91a2/src/Sql/SqlMysql.php#L178
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L67
Escaped Mutant for Mutator "Foreach_":
--- Original
+++ New
@@ @@
private function listTablesQuoted(string $out) : array
{
$tables = $this->listTables($out);
- foreach ($tables as &$table) {
+ foreach (array() as &$table) {
$table = "`{$table}`";
}
return $tables;
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L70
Escaped Mutant for Mutator "ArrayOneItem":
--- Original
+++ New
@@ @@
foreach ($tables as &$table) {
$table = "`{$table}`";
}
- return $tables;
+ return count($tables) > 1 ? array_slice($tables, 0, 1, true) : $tables;
}
protected function getCloudFilesDir(EnvironmentResponse $chosenEnvironment, string $site) : string
{
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L366
Escaped Mutant for Mutator "IfNegation":
--- Original
+++ New
@@ @@
}
private function dropDbTables(string $dbHost, string $dbUser, string $dbName, string $dbPassword, ?\Closure $outputCallback = NULL) : void
{
- if ($outputCallback) {
+ if (!$outputCallback) {
$outputCallback('out', "Dropping tables from database {$dbName}");
}
$this->localMachineHelper->checkRequiredBinariesExist(['mysql']);
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L367
Escaped Mutant for Mutator "FunctionCallRemoval":
--- Original
+++ New
@@ @@
private function dropDbTables(string $dbHost, string $dbUser, string $dbName, string $dbPassword, ?\Closure $outputCallback = NULL) : void
{
if ($outputCallback) {
- $outputCallback('out', "Dropping tables from database {$dbName}");
+
}
$this->localMachineHelper->checkRequiredBinariesExist(['mysql']);
$command = ['mysql', '--host', $dbHost, '--user', $dbUser, $dbName, '--silent', '-e', 'SHOW TABLES;'];
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L384
Escaped Mutant for Mutator "Concat":
--- Original
+++ New
@@ @@
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
$tables = $this->listTablesQuoted($process->getOutput());
if ($tables) {
- $sql = 'DROP TABLE ' . implode(', ', $tables);
+ $sql = implode(', ', $tables) . 'DROP TABLE ';
$command = ['mysql', '--host', $dbHost, '--user', $dbUser, $dbName, '-e', $sql];
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
if (!$process->isSuccessful()) {
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L384
Escaped Mutant for Mutator "ConcatOperandRemoval":
--- Original
+++ New
@@ @@
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
$tables = $this->listTablesQuoted($process->getOutput());
if ($tables) {
- $sql = 'DROP TABLE ' . implode(', ', $tables);
+ $sql = implode(', ', $tables);
$command = ['mysql', '--host', $dbHost, '--user', $dbUser, $dbName, '-e', $sql];
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
if (!$process->isSuccessful()) {
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L384
Escaped Mutant for Mutator "ConcatOperandRemoval":
--- Original
+++ New
@@ @@
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
$tables = $this->listTablesQuoted($process->getOutput());
if ($tables) {
- $sql = 'DROP TABLE ' . implode(', ', $tables);
+ $sql = 'DROP TABLE ';
$command = ['mysql', '--host', $dbHost, '--user', $dbUser, $dbName, '-e', $sql];
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
if (!$process->isSuccessful()) {
|
Mutation Testing:
src/Command/Pull/PullCommandBase.php#L385
Escaped Mutant for Mutator "ArrayItemRemoval":
--- Original
+++ New
@@ @@
$tables = $this->listTablesQuoted($process->getOutput());
if ($tables) {
$sql = 'DROP TABLE ' . implode(', ', $tables);
- $command = ['mysql', '--host', $dbHost, '--user', $dbUser, $dbName, '-e', $sql];
+ $command = ['--host', $dbHost, '--user', $dbUser, $dbName, '-e', $sql];
$process = $this->localMachineHelper->execute($command, $outputCallback, NULL, FALSE, NULL, ['MYSQL_PWD' => $dbPassword]);
if (!$process->isSuccessful()) {
throw new AcquiaCliException('Unable to drop tables from database. {message}', ['message' => $process->getErrorOutput()]);
|