From 3547889ad58435fc2e7374c8b6bf64dd9902abcd Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 6 Jul 2017 10:04:35 +0200 Subject: [PATCH] Fixed InstallCommandTest --- .../src/Command/Install/InstallCommand.php | 1 - .../Command/Install/InstallCommandTest.php | 94 ++++++++----------- 2 files changed, 37 insertions(+), 58 deletions(-) diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php index 641fb552..d6ee3ea2 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -4,7 +4,6 @@ namespace Shlinkio\Shlink\CLI\Command\Install; use Shlinkio\Shlink\CLI\Install\ConfigCustomizerPluginManagerInterface; use Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; -use Shlinkio\Shlink\Common\Util\StringUtilsTrait; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Exception\RuntimeException; diff --git a/module/CLI/test/Command/Install/InstallCommandTest.php b/module/CLI/test/Command/Install/InstallCommandTest.php index 8c76299f..72f80cdd 100644 --- a/module/CLI/test/Command/Install/InstallCommandTest.php +++ b/module/CLI/test/Command/Install/InstallCommandTest.php @@ -5,6 +5,8 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\CLI\Command\Install\InstallCommand; +use Shlinkio\Shlink\CLI\Install\ConfigCustomizerPluginManagerInterface; +use Shlinkio\Shlink\CLI\Install\Plugin\ConfigCustomizerPluginInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Helper\ProcessHelper; use Symfony\Component\Console\Tester\CommandTester; @@ -39,79 +41,57 @@ class InstallCommandTest extends TestCase $this->filesystem = $this->prophesize(Filesystem::class); $this->filesystem->exists(Argument::cetera())->willReturn(false); + $this->configWriter = $this->prophesize(WriterInterface::class); + + $configCustomizer = $this->prophesize(ConfigCustomizerPluginInterface::class); + $configCustomizers = $this->prophesize(ConfigCustomizerPluginManagerInterface::class); + $configCustomizers->get(Argument::cetera())->willReturn($configCustomizer->reveal()); + $app = new Application(); $helperSet = $app->getHelperSet(); $helperSet->set($processHelper->reveal()); $app->setHelperSet($helperSet); - - $this->configWriter = $this->prophesize(WriterInterface::class); - $command = new InstallCommand($this->configWriter->reveal(), $this->filesystem->reveal()); + $command = new InstallCommand( + $this->configWriter->reveal(), + $this->filesystem->reveal(), + $configCustomizers->reveal() + ); $app->add($command); $questionHelper = $command->getHelper('question'); - $questionHelper->setInputStream($this->createInputStream()); +// $questionHelper->setInputStream($this->createInputStream()); $this->commandTester = new CommandTester($command); } - protected function createInputStream() - { - $stream = fopen('php://memory', 'rb+', false); - fwrite($stream, <<configWriter->toFile(Argument::any(), [ - 'app_options' => [ - 'secret_key' => 'my_secret', - ], - 'entity_manager' => [ - 'connection' => [ - 'driver' => 'pdo_mysql', - 'dbname' => 'shlink_db', - 'user' => 'alejandro', - 'password' => '1234', - 'host' => 'localhost', - 'port' => '3306', - 'driverOptions' => [ - \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', - ] - ], - ], - 'translator' => [ - 'locale' => 'en', - ], - 'cli' => [ - 'locale' => 'es', - ], - 'url_shortener' => [ - 'domain' => [ - 'schema' => 'http', - 'hostname' => 'doma.in', - ], - 'shortcode_chars' => 'abc123BCA', - ], - ], false)->shouldBeCalledTimes(1); + $this->configWriter->toFile(Argument::any(), Argument::type('array'), false)->shouldBeCalledTimes(1); $this->commandTester->execute([ 'command' => 'shlink:install',