diff --git a/.github/workflows/drs_ci.yml b/.github/workflows/drs_ci.yml index 137374a..16f1964 100644 --- a/.github/workflows/drs_ci.yml +++ b/.github/workflows/drs_ci.yml @@ -48,7 +48,7 @@ jobs: ../orca/bin/ci/after_script.sh PHPUNIT_TESTS: name: "Run PHPUnit tests for CORE: ${{ matrix.orca-job }}, PHP: ${{ matrix.php-version }}" - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 strategy: matrix: php-version: @@ -58,11 +58,16 @@ jobs: orca-job: - ISOLATED_TEST_ON_CURRENT - INTEGRATED_TEST_ON_PREVIOUS_MINOR + - ISOLATED_TEST_ON_NEXT_MAJOR_LATEST_MINOR_BETA_OR_LATER exclude: - orca-job: INTEGRATED_TEST_ON_PREVIOUS_MINOR php-version: 8.3 - orca-job: INTEGRATED_TEST_ON_PREVIOUS_MINOR php-version: 8.2 + - orca-job: ISOLATED_TEST_ON_NEXT_MAJOR_LATEST_MINOR_BETA_OR_LATER + php-version: 8.1 + - orca-job: ISOLATED_TEST_ON_NEXT_MAJOR_LATEST_MINOR_BETA_OR_LATER + php-version: 8.2 env: ORCA_JOB: ${{ matrix.orca-job }} CI: TRUE diff --git a/composer.json b/composer.json index 36d22d3..0744c5e 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "php": ">=8.1", "composer-plugin-api": "^2", "acquia/drupal-environment-detector": "^1.5.3", - "consolidation/config": "^2.0.0", - "drush/drush": "^11.6 || ^12", + "consolidation/config": "^2 || ^3", + "drush/drush": "^12 || ^13", "grasmash/yaml-expander": "^3.0", "loophp/phposinfo": "^1.7.1" }, diff --git a/src/Config/ConfigInitializer.php b/src/Config/ConfigInitializer.php index 2e3c9d6..470d02b 100644 --- a/src/Config/ConfigInitializer.php +++ b/src/Config/ConfigInitializer.php @@ -3,9 +3,9 @@ namespace Acquia\Drupal\RecommendedSettings\Config; use Acquia\Drupal\RecommendedSettings\Helpers\EnvironmentDetector; -use Consolidation\Config\Config; use Consolidation\Config\ConfigInterface; use Consolidation\Config\Loader\YamlConfigLoader; +use Drush\Config\DrushConfig; use Symfony\Component\Console\Input\InputInterface; /** @@ -18,7 +18,7 @@ class ConfigInitializer { /** * Config. */ - protected Config $config; + protected DrushConfig $config; /** * Loader. @@ -43,7 +43,7 @@ class ConfigInitializer { /** * ConfigInitializer constructor. * - * @param \Consolidation\Config\ConfigInterface|\Consolidation\Config\Config $config + * @param \Consolidation\Config\ConfigInterface|\Drush\Config\DrushConfig $config * The config object. * @param \Symfony\Component\Console\Input\InputInterface|null $input * An input object or null. @@ -147,7 +147,7 @@ protected function loadSiteConfig(): ConfigInitializer { * @param string[] $data * An array of data. */ - public function addConfig(array $data): Config { + public function addConfig(array $data): DrushConfig { $this->processor->add($data); return $this->config; } @@ -170,7 +170,7 @@ protected function determineEnvironment(): string { /** * Process config. */ - public function processConfig(): Config { + public function processConfig(): DrushConfig { $this->config->replace($this->processor->export()); return $this->config; } diff --git a/src/Config/DefaultConfig.php b/src/Config/DefaultConfig.php index 99e92d5..0143b1b 100644 --- a/src/Config/DefaultConfig.php +++ b/src/Config/DefaultConfig.php @@ -2,12 +2,10 @@ namespace Acquia\Drupal\RecommendedSettings\Config; -use Consolidation\Config\Config; - /** * The configuration for settings. */ -class DefaultConfig extends Config { +class DefaultConfig extends DefaultDrushConfig { /** * Config Constructor. diff --git a/src/Config/DefaultDrushConfig.php b/src/Config/DefaultDrushConfig.php index 5f37f72..7b55ddc 100644 --- a/src/Config/DefaultDrushConfig.php +++ b/src/Config/DefaultDrushConfig.php @@ -2,13 +2,12 @@ namespace Acquia\Drupal\RecommendedSettings\Config; -use Consolidation\Config\Config; use Drush\Config\DrushConfig; /** * The configuration for settings. */ -class DefaultDrushConfig extends Config { +class DefaultDrushConfig extends DrushConfig { /** * Config Constructor. @@ -16,16 +15,35 @@ class DefaultDrushConfig extends Config { * @param \Drush\Config\DrushConfig $config * The drush config object. */ - public function __construct(DrushConfig $config) { - $config->set('repo.root', $config->get("runtime.project")); - $config->set('docroot', $config->get("options.root")); - $config->set('composer.bin', $config->get("drush.vendor-dir") . '/bin'); - if ($config->get("options.ansi")) { - $config->set('drush.ansi', $config->get("options.ansi")); + public function __construct(?DrushConfig $config = NULL) { + parent::__construct(); + if ($config) { + $this->set('repo.root', $config->get("runtime.project")); + $this->set('docroot', $config->get("options.root")); + $this->set('composer.bin', $config->get("drush.vendor-dir") . '/bin'); + if ($config->get("options.ansi") !== NULL) { + $this->set('drush.ansi', $config->get("options.ansi")); + } + $this->set('drush.bin', $config->get("runtime.drush-script")); + $this->setDefault('drush.alias', "self"); + $this->combine($config->export()); } - $config->set('drush.bin', $config->get("runtime.drush-script")); - $config->setDefault('drush.alias', "self"); - parent::__construct($config->export()); + } + + /** + * {@inheritdoc} + */ + public function combine($data) { + $this->getContext(self::PROCESS_CONTEXT)->combine($data); + return $this; + } + + /** + * {@inheritdoc} + */ + public function replace($data) { + $this->getContext(self::PROCESS_CONTEXT)->replace($data); + return $this; } } diff --git a/tests/packages_alter.yml b/tests/packages_alter.yml index ce3522b..e170d2d 100644 --- a/tests/packages_alter.yml +++ b/tests/packages_alter.yml @@ -4,9 +4,9 @@ acquia/drupal-recommended-settings: drush/drush: is_company_package: false core_matrix: - 10.1.x: - version: 11.x - version_dev: 11.x - '*': + 10.x: version: 12.x - version_dev: 12.x-dev \ No newline at end of file + version_dev: 12.x-dev + '*': + version: 13.x + version_dev: 13.x-dev diff --git a/tests/src/CommandsTestBase.php b/tests/src/CommandsTestBase.php index a0b1b62..f8b6ae6 100644 --- a/tests/src/CommandsTestBase.php +++ b/tests/src/CommandsTestBase.php @@ -6,12 +6,12 @@ use Acquia\Drupal\RecommendedSettings\Tests\Helpers\NullLogOutputStylers; use Acquia\Drupal\RecommendedSettings\Tests\Traits\OutputAwareTrait; use Consolidation\Log\Logger; +use Drush\Config\DrushConfig; use League\Container\Container; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Robo\Collection\CollectionBuilder; use Robo\Common\BuilderAwareTrait; -use Robo\Config\Config; use Robo\Robo; use Robo\Tasks; use Symfony\Component\Console\Output\NullOutput; @@ -49,7 +49,7 @@ protected function createContainer(?ContainerInterface $container = NULL): void $output = new NullOutput(); $this->setOutput($output); - $config = new Config(); + $config = new DrushConfig(); $this->setConfig($config); $logger = new Logger($this->getOutput()); $null_log_output = new NullLogOutputStylers; diff --git a/tests/src/Functional/Config/ConfigInitializerTest.php b/tests/src/Functional/Config/ConfigInitializerTest.php index 1c1bff5..e34cc25 100644 --- a/tests/src/Functional/Config/ConfigInitializerTest.php +++ b/tests/src/Functional/Config/ConfigInitializerTest.php @@ -3,8 +3,8 @@ namespace Acquia\Drupal\RecommendedSettings\Tests\Functional\Config; use Acquia\Drupal\RecommendedSettings\Config\ConfigInitializer; +use Acquia\Drupal\RecommendedSettings\Config\DefaultDrushConfig; use Acquia\Drupal\RecommendedSettings\Tests\FunctionalTestBase; -use Consolidation\Config\Config; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\StringInput; @@ -22,7 +22,7 @@ class ConfigInitializerTest extends FunctionalTestBase { * @throws \ReflectionException */ public function testSetSite(): void { - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $method = $this->getReflectionMethod($config_initializer::class, "setSite"); @@ -46,7 +46,7 @@ public function testSetSite(): void { * @throws \ReflectionException */ public function testDetermineSite(): void { - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $method = $this->getReflectionMethod($config_initializer::class, "determineSite"); $result = $method->invoke($config_initializer); @@ -74,7 +74,7 @@ public function testDetermineSite(): void { */ public function testDetermineEnvironment(): void { putenv("CI="); - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $method = $this->getReflectionMethod($config_initializer::class, "determineEnvironment"); $result = $method->invoke($config_initializer); @@ -85,7 +85,7 @@ public function testDetermineEnvironment(): void { $this->assertSame("ci", $result); putenv("CI="); - $config = new Config(); + $config = new DefaultDrushConfig(); $config->set("environment", "dev"); $config_initializer = new ConfigInitializer($config); $method = $this->getReflectionMethod($config_initializer::class, "determineEnvironment"); @@ -98,7 +98,7 @@ public function testDetermineEnvironment(): void { */ public function testInitialize(): void { putenv("CI="); - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $config_initializer->initialize(); $this->assertEquals($config_initializer->processConfig()->export(), [ @@ -122,7 +122,7 @@ public function testInitialize(): void { ]); putenv("CI=true"); - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $config_initializer->initialize(); @@ -141,7 +141,7 @@ public function testInitialize(): void { */ public function testLoadAllConfig(): void { putenv("CI="); - $config = new Config(); + $config = new DefaultDrushConfig(); $config_initializer = new ConfigInitializer($config); $config = $config_initializer->initialize()->loadAllConfig()->processConfig(); $this->assertEquals($config->export(), [ @@ -161,7 +161,7 @@ public function testLoadAllConfig(): void { ], ]); - $config = new Config(); + $config = new DefaultDrushConfig(); $project_root = $this->getProjectRoot(); $drupal_root = $this->getDrupalRoot(); $config->set("repo.root", $project_root); @@ -191,7 +191,7 @@ public function testLoadAllConfig(): void { ], ]); - $config = new Config(); + $config = new DefaultDrushConfig(); $config->set("repo.root", $project_root); $config->set("docroot", $this->getDrupalRoot()); $config_initializer = new ConfigInitializer($config); diff --git a/tests/src/unit/Robo/Config/ConfigAwareTraitTest.php b/tests/src/unit/Robo/Config/ConfigAwareTraitTest.php index 0a6c5ad..eb17529 100644 --- a/tests/src/unit/Robo/Config/ConfigAwareTraitTest.php +++ b/tests/src/unit/Robo/Config/ConfigAwareTraitTest.php @@ -20,15 +20,19 @@ class ConfigAwareTraitTest extends TestCase { * Tests the getConfigValue() for ConfigAwareTrait trait. */ public function testGetConfigValue(): void { + $this->config = new DrushConfig(); + // Tests when no value exist for the key, then default value must return. $this->assertEquals( - "/var/www/html/acms.prod/vendor", - $this->getConfigValue("composer.bin", "/var/www/html/acms.prod/vendor"), + "/var/www/html/acms.prod/vendor/bin", + $this->getConfigValue("composer.bin", "/var/www/html/acms.prod/vendor/bin"), ); - $config = new DrushConfig(); - $config->set("runtime.project", "/var/www/html/acms.prod"); - $config->set("options.root", "/var/www/html/acms.prod/docroot"); - $drush_config = new DefaultDrushConfig($config); - $this->setConfig($drush_config); + $drush_config = new DrushConfig(); + $drush_config->set("runtime.project", "/var/www/html/acms.prod"); + $drush_config->set("options.root", "/var/www/html/acms.prod/docroot"); + $drush_config->set("drush.vendor-dir", $drush_config->get("runtime.project") . "/vendor"); + $drush_config->set("options.root", "/var/www/html/acms.prod"); + $default_drush_config = new DefaultDrushConfig($drush_config); + $this->setConfig($default_drush_config); $this->assertEquals("/var/www/html/acms.prod", $this->getConfigValue("repo.root")); }