Fixed consig customizer tests

This commit is contained in:
Alejandro Celaya
2018-10-06 10:05:25 +02:00
parent fa595f7aa3
commit 3b95925217
9 changed files with 104 additions and 110 deletions

View File

@@ -22,17 +22,14 @@ class ApplicationConfigCustomizer implements ConfigCustomizerInterface
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('APPLICATION');
$app = $appConfig->getApp();
$keysToAskFor = $appConfig->hasApp() && $io->confirm('Do you want to keep imported application config?')
? array_diff(self::EXPECTED_KEYS, array_keys($app))
: self::EXPECTED_KEYS;
$keysToAskFor = $appConfig->hasApp() ? array_diff(self::EXPECTED_KEYS, array_keys($app)) : self::EXPECTED_KEYS;
if (empty($keysToAskFor)) {
return;
}
$io->title('APPLICATION');
foreach ($keysToAskFor as $key) {
$app[$key] = $this->ask($io, $key);
}

View File

@@ -53,10 +53,9 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface
*/
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('DATABASE');
$titlePrinted = false;
$db = $appConfig->getDatabase();
$doImport = $appConfig->hasDatabase() && $io->confirm('Do you want to keep imported database config?');
$doImport = $appConfig->hasDatabase();
$keysToAskFor = $doImport ? array_diff(self::EXPECTED_KEYS, array_keys($db)) : self::EXPECTED_KEYS;
// If the user selected to keep DB, try to import SQLite database
@@ -70,6 +69,8 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface
// If the driver is one of the params to ask for, ask for it first
if (contains(self::DRIVER, $keysToAskFor)) {
$io->title('DATABASE');
$titlePrinted = true;
$db[self::DRIVER] = $this->ask($io, self::DRIVER);
$keysToAskFor = array_diff($keysToAskFor, [self::DRIVER]);
}
@@ -79,7 +80,9 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface
$keysToAskFor = array_diff($keysToAskFor, self::DRIVER_DEPENDANT_OPTIONS);
}
// Iterate any remaining option and ask for it
if (! $titlePrinted && ! empty($keysToAskFor)) {
$io->title('DATABASE');
}
foreach ($keysToAskFor as $key) {
$db[$key] = $this->ask($io, $key, $db);
}

View File

@@ -21,10 +21,8 @@ class LanguageConfigCustomizer implements ConfigCustomizerInterface
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('LANGUAGE');
$lang = $appConfig->getLanguage();
$keysToAskFor = $appConfig->hasLanguage() && $io->confirm('Do you want to keep imported language?')
$keysToAskFor = $appConfig->hasLanguage()
? array_diff(self::EXPECTED_KEYS, array_keys($lang))
: self::EXPECTED_KEYS;
@@ -32,6 +30,7 @@ class LanguageConfigCustomizer implements ConfigCustomizerInterface
return;
}
$io->title('LANGUAGE');
foreach ($keysToAskFor as $key) {
$lang[$key] = $this->ask($io, $key);
}

View File

@@ -28,16 +28,15 @@ class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('URL SHORTENER');
$urlShortener = $appConfig->getUrlShortener();
$doImport = $appConfig->hasUrlShortener() && $io->confirm('Do you want to keep imported URL shortener config?');
$doImport = $appConfig->hasUrlShortener();
$keysToAskFor = $doImport ? array_diff(self::EXPECTED_KEYS, array_keys($urlShortener)) : self::EXPECTED_KEYS;
if (empty($keysToAskFor)) {
return;
}
$io->title('URL SHORTENER');
foreach ($keysToAskFor as $key) {
$urlShortener[$key] = $this->ask($io, $key);
}