mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-23 08:06:33 +00:00
Remove InstallCommandMock
This commit is contained in:
parent
c372d68cc1
commit
8f20df6559
3 changed files with 23 additions and 27 deletions
|
@ -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,
|
||||
|
|
|
@ -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([
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Wallabag\CoreBundle\Mock;
|
||||
|
||||
use Wallabag\CoreBundle\Command\InstallCommand;
|
||||
|
||||
/**
|
||||
* This mock aims to speed the test of InstallCommand by avoid calling external command
|
||||
* like all doctrine commands.
|
||||
*
|
||||
* This speed the test but as a downside, it doesn't allow to fully test the InstallCommand
|
||||
*
|
||||
* Launching tests to avoid doctrine command:
|
||||
* phpunit --exclude-group command-doctrine
|
||||
*/
|
||||
class InstallCommandMock extends InstallCommand
|
||||
{
|
||||
protected function runCommand($command, $parameters = [])
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue