diff --git a/module/CLI/test/Command/Install/InstallCommandTest.php b/module/CLI/test/Command/Install/InstallCommandTest.php new file mode 100644 index 00000000..6fb2ee79 --- /dev/null +++ b/module/CLI/test/Command/Install/InstallCommandTest.php @@ -0,0 +1,101 @@ +prophesize(ProcessHelper::class); + $processHelper->getName()->willReturn('process'); + $processHelper->setHelperSet(Argument::any())->willReturn(null); + $processHelper->run(Argument::cetera())->willReturn(null); + + $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()); + $app->add($command); + + $questionHelper = $command->getHelper('question'); + $questionHelper->setInputStream($this->createInputStream()); + $this->commandTester = new CommandTester($command); + } + + protected function createInputStream() + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, <<configWriter->toFile(Argument::any(), [ + 'app_options' => [ + 'secret_key' => 'my_secret', + ], + 'entity_manager' => [ + 'connection' => [ + 'driver' => 'pdo_mysql', + 'dbname' => 'shlink_db', + 'user' => 'alejandro', + 'password' => '1234', + ], + ], + 'translator' => [ + 'locale' => 'en', + ], + 'cli' => [ + 'locale' => 'es', + ], + 'url_shortener' => [ + 'domain' => [ + 'schema' => 'http', + 'hostname' => 'doma.in', + ], + 'shortcode_chars' => 'abc123BCA', + ], + ], false)->shouldBeCalledTimes(1); + $this->commandTester->execute([ + 'command' => 'shlink:install', + ]); + } +}