Added --no-interaction to commands run internally from shlink DB commands

This commit is contained in:
Alejandro Celaya 2020-03-15 17:25:39 +01:00
parent d32112fe7e
commit 6ddd70d21d
3 changed files with 7 additions and 5 deletions

View file

@ -11,8 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use function array_unshift;
abstract class AbstractDatabaseCommand extends AbstractLockedCommand abstract class AbstractDatabaseCommand extends AbstractLockedCommand
{ {
private ProcessHelper $processHelper; private ProcessHelper $processHelper;
@ -27,7 +25,7 @@ abstract class AbstractDatabaseCommand extends AbstractLockedCommand
protected function runPhpCommand(OutputInterface $output, array $command): void protected function runPhpCommand(OutputInterface $output, array $command): void
{ {
array_unshift($command, $this->phpBinary); $command = [$this->phpBinary, ...$command, '--no-interaction'];
$this->processHelper->mustRun($output, $command); $this->processHelper->mustRun($output, $command);
} }

View file

@ -18,6 +18,7 @@ use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
class CreateDatabaseCommandTest extends TestCase class CreateDatabaseCommandTest extends TestCase
{ {
@ -114,7 +115,8 @@ class CreateDatabaseCommandTest extends TestCase
'/usr/local/bin/php', '/usr/local/bin/php',
CreateDatabaseCommand::DOCTRINE_SCRIPT, CreateDatabaseCommand::DOCTRINE_SCRIPT,
CreateDatabaseCommand::DOCTRINE_CREATE_SCHEMA_COMMAND, CreateDatabaseCommand::DOCTRINE_CREATE_SCHEMA_COMMAND,
], Argument::cetera()); '--no-interaction',
], Argument::cetera())->willReturn(new Process([]));
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();

View file

@ -15,6 +15,7 @@ use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
class MigrateDatabaseCommandTest extends TestCase class MigrateDatabaseCommandTest extends TestCase
{ {
@ -53,7 +54,8 @@ class MigrateDatabaseCommandTest extends TestCase
'/usr/local/bin/php', '/usr/local/bin/php',
MigrateDatabaseCommand::DOCTRINE_MIGRATIONS_SCRIPT, MigrateDatabaseCommand::DOCTRINE_MIGRATIONS_SCRIPT,
MigrateDatabaseCommand::DOCTRINE_MIGRATE_COMMAND, MigrateDatabaseCommand::DOCTRINE_MIGRATE_COMMAND,
], Argument::cetera()); '--no-interaction',
], Argument::cetera())->willReturn(new Process([]));
$this->commandTester->execute([]); $this->commandTester->execute([]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();