diff --git a/.vortex/installer/src/Command/InstallCommand.php b/.vortex/installer/src/Command/InstallCommand.php index d85b07528..3bb0ad62a 100644 --- a/.vortex/installer/src/Command/InstallCommand.php +++ b/.vortex/installer/src/Command/InstallCommand.php @@ -78,7 +78,7 @@ protected function configure(): void { $this->addOption(static::OPTION_ROOT, NULL, InputOption::VALUE_REQUIRED, 'Path to the root for file path resolution. If not specified, current directory is used.'); $this->addOption(static::OPTION_NO_INTERACTION, 'n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'); - $this->addOption(static::OPTION_CONFIG, 'c', InputOption::VALUE_REQUIRED, 'A JSON string with options.'); + $this->addOption(static::OPTION_CONFIG, 'c', InputOption::VALUE_REQUIRED, 'A JSON string with options or a path to a JSON file.'); $this->addOption(static::OPTION_URI, 'l', InputOption::VALUE_REQUIRED, 'Remote or local repository URI with an optional git ref set after @.'); $this->addOption(static::OPTION_NO_CLEANUP, NULL, InputOption::VALUE_NONE, 'Do not remove installer after successful installation.'); } @@ -207,7 +207,12 @@ protected function checkRequirements(): void { * Array of CLI options. */ protected function resolveOptions(array $arguments, array $options): void { - $config = isset($options[static::OPTION_CONFIG]) && is_scalar($options[static::OPTION_CONFIG]) ? strval($options[static::OPTION_CONFIG]) : '{}'; + $config = '{}'; + if (isset($options[static::OPTION_CONFIG]) && is_scalar($options[static::OPTION_CONFIG])) { + $config_candidate = strval($options[static::OPTION_CONFIG]); + $config = is_file($config_candidate) ? (string) file_get_contents($config_candidate) : $config_candidate; + } + $this->config = Config::fromString($config); $this->config->setQuiet($options[static::OPTION_QUIET]); diff --git a/.vortex/installer/src/Prompts/PromptManager.php b/.vortex/installer/src/Prompts/PromptManager.php index c74296038..17649dcf7 100644 --- a/.vortex/installer/src/Prompts/PromptManager.php +++ b/.vortex/installer/src/Prompts/PromptManager.php @@ -506,14 +506,21 @@ private function args(string $handler_class, mixed $default_override = NULL, arr // Find appropriate default value. $default_from_handler = $handler->default($responses); - - $env_var = static::makeEnvName($id); - $env_val = Env::get($env_var); + // Create the env var name. + $var_name = static::makeEnvName($id); + // Get from config. + $config_val = $this->config->get($var_name); + $default_from_config = is_null($config_val) ? NULL : $config_val; + // Get from env. + $env_val = Env::get($var_name); $default_from_env = is_null($env_val) ? NULL : Env::toValue($env_val); - + // Get from discovery. $default_from_discovery = $this->handlers[$id]->discover(); - if (!is_null($default_from_env)) { + if (!is_null($default_from_config)) { + $default = $default_from_config; + } + elseif (!is_null($default_from_env)) { $default = $default_from_env; } elseif (!is_null($default_from_discovery)) { diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.ahoy.yml b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.ahoy.yml new file mode 100644 index 000000000..becee6a60 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.ahoy.yml @@ -0,0 +1,12 @@ +@@ -99,11 +99,6 @@ + usage: Run Drush commands in the CLI service container. + cmd: ahoy cli "vendor/bin/drush -l \${VORTEX_LOCALDEV_URL} $*" + +- flush-valkey: +- aliases: [flush-redis] +- usage: Flush Valkey cache. +- cmd: docker compose exec valkey valkey-cli flushall +- + # ---------------------------------------------------------------------------- + # Application commands. + # ---------------------------------------------------------------------------- diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.env b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.env new file mode 100644 index 000000000..0f7539740 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/.env @@ -0,0 +1,11 @@ +@@ -70,10 +70,6 @@ + # Shield message. + DRUPAL_SHIELD_PRINT="Restricted access." + +-# Enable Redis/Valkey integration. +-# See settings.redis.php for details. +-DRUPAL_REDIS_ENABLED=1 +- + # Enable ClamAV integration. + DRUPAL_CLAMAV_ENABLED=1 + diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/README.md b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/README.md new file mode 100644 index 000000000..816cff112 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/README.md @@ -0,0 +1,16 @@ +@@ -2,12 +2,12 @@ + + # star wars + +-Drupal 11 implementation of star wars for star wars Org ++Drupal 11 implementation of star wars for My custom org + +-[![Database, Build, Test and Deploy](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml/badge.svg)](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml) ++[![Database, Build, Test and Deploy](https://github.com/my_custom_org/star_wars/actions/workflows/build-test-deploy.yml/badge.svg)](https://github.com/my_custom_org/star_wars/actions/workflows/build-test-deploy.yml) + + ![Drupal 11](https://img.shields.io/badge/Drupal-11-blue.svg) +-[![codecov](https://codecov.io/gh/star_wars_org/star_wars/graph/badge.svg)](https://codecov.io/gh/star_wars_org/star_wars) ++[![codecov](https://codecov.io/gh/my_custom_org/star_wars/graph/badge.svg)](https://codecov.io/gh/my_custom_org/star_wars) + + ![Automated updates](https://img.shields.io/badge/Automated%20updates-RenovateBot-brightgreen.svg) + diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/composer.json b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/composer.json new file mode 100644 index 000000000..0a34d0ecc --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/composer.json @@ -0,0 +1,17 @@ +@@ -1,6 +1,6 @@ + { +- "name": "star_wars_org/star_wars", +- "description": "Drupal 11 implementation of star wars for star wars Org", ++ "name": "my_custom_org/star_wars", ++ "description": "Drupal 11 implementation of star wars for My custom org", + "license": "proprietary", + "type": "project", + "require": { +@@ -17,7 +17,6 @@ + "drupal/environment_indicator": "__VERSION__", + "drupal/pathauto": "__VERSION__", + "drupal/redirect": "__VERSION__", +- "drupal/redis": "__VERSION__", + "drupal/robotstxt": "__VERSION__", + "drupal/search_api": "__VERSION__", + "drupal/search_api_solr": "__VERSION__", diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/docker-compose.yml b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/docker-compose.yml new file mode 100644 index 000000000..be92b8373 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/docker-compose.yml @@ -0,0 +1,29 @@ +@@ -52,8 +52,6 @@ + # Drupal Shield credentials. + DRUPAL_SHIELD_USER: ${DRUPAL_SHIELD_USER:-} + DRUPAL_SHIELD_PASS: ${DRUPAL_SHIELD_PASS:-} +- # Valkey integration flag. +- DRUPAL_REDIS_ENABLED: ${DRUPAL_REDIS_ENABLED:-} + + # The default user under which the containers should run. + x-user: &default-user +@@ -146,9 +144,6 @@ + ports: + - '3306' # Database port in a container. Find port on host with `ahoy info` or `docker compose port database 3306`. + +- valkey: +- image: uselagoon/valkey-8:__VERSION__ +- + solr: + build: + context: . +@@ -196,8 +191,7 @@ + - clamav + - cli + - database +- - valkey +- command: database:3306 clamav:3310 valkey:6379 ++ command: database:3306 clamav:3310 + + networks: ### Use external networks locally. Automatically removed in CI. + amazeeio-network: ### Automatically removed in CI. diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/package.json b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/package.json new file mode 100644 index 000000000..961ff089b --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/package.json @@ -0,0 +1,8 @@ +@@ -1,6 +1,6 @@ + { + "name": "star_wars", +- "description": "Drupal 11 implementation of star wars for star wars Org", ++ "description": "Drupal 11 implementation of star wars for My custom org", + "license": "proprietary", + "private": true, + "engines": { diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/scripts/custom/provision-10-example.sh b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/scripts/custom/provision-10-example.sh new file mode 100644 index 000000000..b33592c40 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/scripts/custom/provision-10-example.sh @@ -0,0 +1,10 @@ +@@ -42,9 +42,6 @@ + task "Installing contrib modules." + drush pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect robotstxt shield stage_file_proxy + +- task "Installing Redis module." +- drush pm:install redis || true +- + task "Installing and configuring ClamAV." + drush pm:install clamav + drush config-set clamav.settings mode_daemon_tcpip.hostname clamav diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/tests/behat/features/-redis.feature b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/tests/behat/features/-redis.feature new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/tests/phpunit/Drupal/SwitchableSettingsTest.php b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/tests/phpunit/Drupal/SwitchableSettingsTest.php new file mode 100644 index 000000000..9639c7b5e --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/tests/phpunit/Drupal/SwitchableSettingsTest.php @@ -0,0 +1,106 @@ +@@ -228,105 +228,6 @@ + } + + /** +- * Test Valkey settings. +- */ +- public function testValkey(): void { +- $this->setEnvVars([ +- 'DRUPAL_REDIS_ENABLED' => 1, +- 'VALKEY_HOST' => 'valkey_host', +- 'VALKEY_SERVICE_PORT' => 1234, +- 'VORTEX_REDIS_EXTENSION_LOADED' => 1, +- ]); +- +- $this->requireSettingsFile(); +- +- $settings['redis.connection']['interface'] = 'PhpRedis'; +- $settings['redis.connection']['host'] = 'valkey_host'; +- $settings['redis.connection']['port'] = 1234; +- $settings['cache']['default'] = 'cache.backend.redis'; +- +- $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); +- unset($this->settings['bootstrap_container_definition']); +- +- $this->assertSettingsContains($settings); +- } +- +- /** +- * Test Valkey partial settings. +- */ +- public function testValkeyPartial(): void { +- $this->setEnvVars([ +- 'DRUPAL_REDIS_ENABLED' => 1, +- 'VALKEY_HOST' => 'valkey_host', +- 'VALKEY_SERVICE_PORT' => 1234, +- 'VORTEX_REDIS_EXTENSION_LOADED' => 0, +- ]); +- +- $this->requireSettingsFile(); +- +- $settings['redis.connection']['interface'] = 'PhpRedis'; +- $settings['redis.connection']['host'] = 'valkey_host'; +- $settings['redis.connection']['port'] = 1234; +- $no_settings['cache']['default'] = 'cache.backend.redis'; +- +- $this->assertArrayNotHasKey('bootstrap_container_definition', $this->settings); +- +- $this->assertSettingsContains($settings); +- $this->assertSettingsNotContains($no_settings); +- } +- +- /** +- * Test Redis settings with REDIS_* environment variables. +- */ +- public function testRedisVariables(): void { +- $this->setEnvVars([ +- 'DRUPAL_REDIS_ENABLED' => 1, +- 'REDIS_HOST' => 'redis_host', +- 'REDIS_SERVICE_PORT' => 6380, +- 'VORTEX_REDIS_EXTENSION_LOADED' => 1, +- ]); +- +- $this->requireSettingsFile(); +- +- $settings['redis.connection']['interface'] = 'PhpRedis'; +- $settings['redis.connection']['host'] = 'redis_host'; +- $settings['redis.connection']['port'] = 6380; +- $settings['cache']['default'] = 'cache.backend.redis'; +- +- $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); +- unset($this->settings['bootstrap_container_definition']); +- +- $this->assertSettingsContains($settings); +- } +- +- /** +- * Test Redis fallback when both VALKEY_* and REDIS_* variables are set. +- */ +- public function testRedisValkeyPrecedence(): void { +- $this->setEnvVars([ +- 'DRUPAL_REDIS_ENABLED' => 1, +- 'VALKEY_HOST' => 'valkey_host', +- 'VALKEY_SERVICE_PORT' => 1234, +- 'REDIS_HOST' => 'redis_host', +- 'REDIS_SERVICE_PORT' => 6380, +- 'VORTEX_REDIS_EXTENSION_LOADED' => 1, +- ]); +- +- $this->requireSettingsFile(); +- +- // VALKEY_* variables should take precedence over REDIS_* variables. +- $settings['redis.connection']['interface'] = 'PhpRedis'; +- $settings['redis.connection']['host'] = 'valkey_host'; +- $settings['redis.connection']['port'] = 1234; +- $settings['cache']['default'] = 'cache.backend.redis'; +- +- $this->assertArrayHasKey('bootstrap_container_definition', $this->settings); +- unset($this->settings['bootstrap_container_definition']); +- +- $this->assertSettingsContains($settings); +- } +- +- /** + * Test Shield config. + */ + #[DataProvider('dataProviderShield')] diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/web/sites/default/includes/modules/-settings.redis.php b/.vortex/installer/tests/Fixtures/install/non_interactive_config_file/web/sites/default/includes/modules/-settings.redis.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.docker/-clamav.dockerfile b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.docker/-clamav.dockerfile new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.docker/config/clamav/-clamav.conf b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.docker/config/clamav/-clamav.conf new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.env b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.env new file mode 100644 index 000000000..c3b943e36 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/.env @@ -0,0 +1,16 @@ +@@ -74,15 +74,6 @@ + # See settings.redis.php for details. + DRUPAL_REDIS_ENABLED=1 + +-# Enable ClamAV integration. +-DRUPAL_CLAMAV_ENABLED=1 +- +-# ClamAV mode. +-# +-# Run ClamAV in either daemon mode by setting it to 0 (or 'daemon') or in +-# executable mode by setting it to 1. +-DRUPAL_CLAMAV_MODE=daemon +- + ################################################################################ + # PROVISION # + ################################################################################ diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/README.md b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/README.md new file mode 100644 index 000000000..2aad41ef6 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/README.md @@ -0,0 +1,16 @@ +@@ -2,12 +2,12 @@ + + # star wars + +-Drupal 11 implementation of star wars for star wars Org ++Drupal 11 implementation of star wars for My other custom org + +-[![Database, Build, Test and Deploy](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml/badge.svg)](https://github.com/star_wars_org/star_wars/actions/workflows/build-test-deploy.yml) ++[![Database, Build, Test and Deploy](https://github.com/my_other_custom_org/star_wars/actions/workflows/build-test-deploy.yml/badge.svg)](https://github.com/my_other_custom_org/star_wars/actions/workflows/build-test-deploy.yml) + + ![Drupal 11](https://img.shields.io/badge/Drupal-11-blue.svg) +-[![codecov](https://codecov.io/gh/star_wars_org/star_wars/graph/badge.svg)](https://codecov.io/gh/star_wars_org/star_wars) ++[![codecov](https://codecov.io/gh/my_other_custom_org/star_wars/graph/badge.svg)](https://codecov.io/gh/my_other_custom_org/star_wars) + + ![Automated updates](https://img.shields.io/badge/Automated%20updates-RenovateBot-brightgreen.svg) + diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/composer.json b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/composer.json new file mode 100644 index 000000000..f3e2b8d09 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/composer.json @@ -0,0 +1,17 @@ +@@ -1,6 +1,6 @@ + { +- "name": "star_wars_org/star_wars", +- "description": "Drupal 11 implementation of star wars for star wars Org", ++ "name": "my_other_custom_org/star_wars", ++ "description": "Drupal 11 implementation of star wars for My other custom org", + "license": "proprietary", + "type": "project", + "require": { +@@ -8,7 +8,6 @@ + "composer/installers": "__VERSION__", + "cweagans/composer-patches": "__VERSION__", + "drupal/admin_toolbar": "__VERSION__", +- "drupal/clamav": "__VERSION__", + "drupal/coffee": "__VERSION__", + "drupal/config_split": "__VERSION__", + "drupal/config_update": "__VERSION__", diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/docker-compose.yml b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/docker-compose.yml new file mode 100644 index 000000000..ea83ab239 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/docker-compose.yml @@ -0,0 +1,31 @@ +@@ -166,17 +166,6 @@ + ports: + - '8983' # Solr port in a container. Find port on host with `ahoy info` or `docker compose port solr 8983`. + +- clamav: +- build: +- context: . +- dockerfile: .docker/clamav.dockerfile +- environment: +- <<: *default-environment +- ports: +- - '3310' # Find port on host with `docker compose port clamav 3310`. +- networks: +- - default +- + # Chrome container, used for browser testing. + chrome: + image: selenium/standalone-chromium:__VERSION__ +@@ -193,11 +182,10 @@ + wait_dependencies: + image: drevops/docker-wait-for-dependencies:__VERSION__ + depends_on: +- - clamav + - cli + - database + - valkey +- command: database:3306 clamav:3310 valkey:6379 ++ command: database:3306 valkey:6379 + + networks: ### Use external networks locally. Automatically removed in CI. + amazeeio-network: ### Automatically removed in CI. diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/package.json b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/package.json new file mode 100644 index 000000000..08be5967b --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/package.json @@ -0,0 +1,8 @@ +@@ -1,6 +1,6 @@ + { + "name": "star_wars", +- "description": "Drupal 11 implementation of star wars for star wars Org", ++ "description": "Drupal 11 implementation of star wars for My other custom org", + "license": "proprietary", + "private": true, + "engines": { diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/scripts/custom/provision-10-example.sh b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/scripts/custom/provision-10-example.sh new file mode 100644 index 000000000..84cb13a1f --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/scripts/custom/provision-10-example.sh @@ -0,0 +1,11 @@ +@@ -45,10 +45,6 @@ + task "Installing Redis module." + drush pm:install redis || true + +- task "Installing and configuring ClamAV." +- drush pm:install clamav +- drush config-set clamav.settings mode_daemon_tcpip.hostname clamav +- + task "Installing Solr search modules." + drush pm:install search_api search_api_solr + diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/tests/behat/features/-clamav.feature b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/tests/behat/features/-clamav.feature new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/tests/phpunit/Drupal/SwitchableSettingsTest.php b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/tests/phpunit/Drupal/SwitchableSettingsTest.php new file mode 100644 index 000000000..5441d77b3 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/tests/phpunit/Drupal/SwitchableSettingsTest.php @@ -0,0 +1,63 @@ +@@ -20,62 +20,6 @@ + class SwitchableSettingsTest extends SettingsTestCase { + + /** +- * Test ClamAV configs in Daemon mode with defaults. +- */ +- public function testClamavDaemonCustom(): void { +- $this->setEnvVars([ +- 'DRUPAL_CLAMAV_ENABLED' => TRUE, +- 'DRUPAL_CLAMAV_MODE' => 'daemon', +- 'CLAMAV_HOST' => 'custom_clamav_host', +- 'CLAMAV_PORT' => 3333, +- ]); +- +- $this->requireSettingsFile(); +- +- $config['clamav.settings']['scan_mode'] = 0; +- $config['clamav.settings']['mode_daemon_tcpip']['hostname'] = 'custom_clamav_host'; +- $config['clamav.settings']['mode_daemon_tcpip']['port'] = 3333; +- +- $this->assertConfigContains($config); +- } +- +- /** +- * Test ClamAV configs in Executable mode. +- */ +- public function testClamavExecutable(): void { +- $this->setEnvVars([ +- 'DRUPAL_CLAMAV_ENABLED' => TRUE, +- 'CLAMAV_HOST' => 'custom_clamav_host', +- 'CLAMAV_PORT' => 3333, +- ]); +- +- $this->requireSettingsFile(); +- +- $config['clamav.settings']['scan_mode'] = 1; +- $config['clamav.settings']['executable_path'] = '/usr/bin/clamscan'; +- +- $this->assertConfigContains($config); +- } +- +- /** +- * Test ClamAV configs in Daemon mode with defaults. +- */ +- public function testClamavDaemonDefaults(): void { +- $this->setEnvVars([ +- 'DRUPAL_CLAMAV_ENABLED' => TRUE, +- 'DRUPAL_CLAMAV_MODE' => 'daemon', +- ]); +- +- $this->requireSettingsFile(); +- +- $config['clamav.settings']['scan_mode'] = 0; +- $config['clamav.settings']['mode_daemon_tcpip']['hostname'] = 'clamav'; +- $config['clamav.settings']['mode_daemon_tcpip']['port'] = 3310; +- +- $this->assertConfigContains($config); +- } +- +- /** + * Test Config Split config. + */ + #[DataProvider('dataProviderConfigSplit')] diff --git a/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/web/sites/default/includes/modules/-settings.clamav.php b/.vortex/installer/tests/Fixtures/install/non_interactive_config_string/web/sites/default/includes/modules/-settings.clamav.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Functional/Handlers/AbstractInstallTestCase.php b/.vortex/installer/tests/Functional/Handlers/AbstractInstallTestCase.php index 8db170789..b9ae5e39b 100644 --- a/.vortex/installer/tests/Functional/Handlers/AbstractInstallTestCase.php +++ b/.vortex/installer/tests/Functional/Handlers/AbstractInstallTestCase.php @@ -18,6 +18,11 @@ */ abstract class AbstractInstallTestCase extends FunctionalTestCase { + /** + * Override options to pass to the install command. + */ + public array $installOptions = []; + protected function setUp(): void { parent::setUp(); @@ -42,7 +47,7 @@ public function testInstall( $before($this); } - $this->runNonInteractiveInstall(); + $this->runNonInteractiveInstall(options: $this->installOptions); $expected = empty($expected) ? ['Welcome to the Vortex non-interactive installer'] : $expected; $this->assertApplicationOutputContains($expected); diff --git a/.vortex/installer/tests/Functional/Handlers/BaselineInstallTest.php b/.vortex/installer/tests/Functional/Handlers/BaselineInstallTest.php index 52149e25c..d94b34b6c 100644 --- a/.vortex/installer/tests/Functional/Handlers/BaselineInstallTest.php +++ b/.vortex/installer/tests/Functional/Handlers/BaselineInstallTest.php @@ -31,6 +31,7 @@ use DrevOps\VortexInstaller\Prompts\PromptManager; use DrevOps\VortexInstaller\Utils\Config; use DrevOps\VortexInstaller\Utils\Downloader; +use DrevOps\VortexInstaller\Utils\File; use DrevOps\VortexInstaller\Utils\Git; use DrevOps\VortexInstaller\Utils\Tui; use PHPUnit\Framework\Attributes\CoversClass; @@ -79,6 +80,35 @@ public static function dataProviderInstall(): array { NULL, ['Welcome to the Vortex non-interactive installer'], ], + + 'non-interactive, config file' => [ + static::cw(function (AbstractInstallTestCase $test): void { + $config_file = static::$tmp . DIRECTORY_SEPARATOR . 'config.json'; + File::dump($config_file, (string) json_encode([ + // Test overriding scalar value. + PromptManager::makeEnvName(Org::id()) => 'My custom org', + // Test overriding array value. + PromptManager::makeEnvName(Services::id()) => [Services::SOLR, Services::CLAMAV], + ])); + $test->installOptions['config'] = $config_file; + }), + NULL, + ['Welcome to the Vortex non-interactive installer'], + ], + + 'non-interactive, config string' => [ + static::cw(function (AbstractInstallTestCase $test): void { + $config_string = (string) json_encode([ + // Test overriding scalar value. + PromptManager::makeEnvName(Org::id()) => 'My other custom org', + // Test overriding array value. + PromptManager::makeEnvName(Services::id()) => [Services::SOLR, Services::VALKEY], + ]); + $test->installOptions['config'] = $config_string; + }), + NULL, + ['Welcome to the Vortex non-interactive installer'], + ], ]; }