Fixed config customizer tests

This commit is contained in:
Alejandro Celaya
2017-12-31 17:45:27 +01:00
parent 2705070063
commit 4d4aafa6db
9 changed files with 83 additions and 140 deletions

View File

@@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Symfony\Component\Console\Style\SymfonyStyle;
abstract class AbstractConfigCustomizer implements ConfigCustomizerInterface
{
/**
* @param SymfonyStyle $io
* @param string $text
* @param string|null $default
* @param bool $allowEmpty
* @return string
*/
protected function ask(SymfonyStyle $io, $text, $default = null, $allowEmpty = false): string
{
if ($default !== null) {
$text .= ' (defaults to ' . $default . ')';
}
do {
$value = $io->ask($text, $default);
if (empty($value) && ! $allowEmpty) {
$io->writeln('<error>Value can\'t be empty</error>');
}
} while (empty($value) && $default === null && ! $allowEmpty);
return $value;
}
}

View File

@@ -7,7 +7,7 @@ use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
use Symfony\Component\Console\Style\SymfonyStyle;
class ApplicationConfigCustomizer extends AbstractConfigCustomizer
class ApplicationConfigCustomizer implements ConfigCustomizerInterface
{
use StringUtilsTrait;

View File

@@ -8,7 +8,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
class DatabaseConfigCustomizer extends AbstractConfigCustomizer
class DatabaseConfigCustomizer implements ConfigCustomizerInterface
{
const DATABASE_DRIVERS = [
'MySQL' => 'pdo_mysql',

View File

@@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Symfony\Component\Console\Style\SymfonyStyle;
class LanguageConfigCustomizer extends AbstractConfigCustomizer
class LanguageConfigCustomizer implements ConfigCustomizerInterface
{
const SUPPORTED_LANGUAGES = ['en', 'es'];

View File

@@ -7,7 +7,7 @@ use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Symfony\Component\Console\Style\SymfonyStyle;
class UrlShortenerConfigCustomizer extends AbstractConfigCustomizer
class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
{
/**
* @param SymfonyStyle $io