From 8f20df6559bbd696ac035c87b3db63218cd089ce Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 3 Sep 2022 02:17:36 +0200 Subject: [PATCH] Remove InstallCommandMock --- .../CoreBundle/Command/InstallCommand.php | 11 ++++++++++ .../CoreBundle/Command/InstallCommandTest.php | 17 +++++++++----- .../CoreBundle/Mock/InstallCommandMock.php | 22 ------------------- 3 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 tests/Wallabag/CoreBundle/Mock/InstallCommandMock.php diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index fa40beac9..17f97b9b7 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -41,6 +41,13 @@ class InstallCommand extends ContainerAwareCommand 'curl_multi_init', ]; + private bool $runOtherCommands = true; + + public function disableRunOtherCommands(): void + { + $this->runOtherCommands = false; + } + protected function configure() { $this @@ -315,6 +322,10 @@ class InstallCommand extends ContainerAwareCommand */ protected function runCommand($command, $parameters = []) { + if (!$this->runOtherCommands) { + return $this; + } + $parameters = array_merge( ['command' => $command], $parameters, diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index 96fa775b6..e81e50fec 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php @@ -14,7 +14,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Tester\CommandTester; -use Tests\Wallabag\CoreBundle\Mock\InstallCommandMock; use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; use Wallabag\CoreBundle\Command\InstallCommand; @@ -89,9 +88,11 @@ class InstallCommandTest extends WallabagCoreTestCase public function testRunInstallCommand() { $application = new Application($this->getClient()->getKernel()); - $application->add(new InstallCommandMock()); + $application->add(new InstallCommand()); + /** @var InstallCommand $command */ $command = $application->find('wallabag:install'); + $command->disableRunOtherCommands(); $tester = new CommandTester($command); $tester->setInputs([ @@ -114,9 +115,11 @@ class InstallCommandTest extends WallabagCoreTestCase public function testRunInstallCommandWithReset() { $application = new Application($this->getClient()->getKernel()); - $application->add(new InstallCommandMock()); + $application->add(new InstallCommand()); + /** @var InstallCommand $command */ $command = $application->find('wallabag:install'); + $command->disableRunOtherCommands(); $tester = new CommandTester($command); $tester->setInputs([ @@ -188,9 +191,11 @@ class InstallCommandTest extends WallabagCoreTestCase public function testRunInstallCommandChooseResetSchema() { $application = new Application($this->getClient()->getKernel()); - $application->add(new InstallCommandMock()); + $application->add(new InstallCommand()); + /** @var InstallCommand $command */ $command = $application->find('wallabag:install'); + $command->disableRunOtherCommands(); $tester = new CommandTester($command); $tester->setInputs([ @@ -257,9 +262,11 @@ class InstallCommandTest extends WallabagCoreTestCase public function testRunInstallCommandNoInteraction() { $application = new Application($this->getClient()->getKernel()); - $application->add(new InstallCommandMock()); + $application->add(new InstallCommand()); + /** @var InstallCommand $command */ $command = $application->find('wallabag:install'); + $command->disableRunOtherCommands(); $tester = new CommandTester($command); $tester->execute([ diff --git a/tests/Wallabag/CoreBundle/Mock/InstallCommandMock.php b/tests/Wallabag/CoreBundle/Mock/InstallCommandMock.php deleted file mode 100644 index 5806bd4d5..000000000 --- a/tests/Wallabag/CoreBundle/Mock/InstallCommandMock.php +++ /dev/null @@ -1,22 +0,0 @@ -