Skip to content

Commit

Permalink
Merge pull request #64 from acquia/develop
Browse files Browse the repository at this point in the history
Merge branch `develop` into `main`
  • Loading branch information
vishalkhode1 authored Jul 9, 2024
2 parents bf269fd + 4f682f8 commit a06796b
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 46 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/drs_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 5 additions & 5 deletions src/Config/ConfigInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -18,7 +18,7 @@ class ConfigInitializer {
/**
* Config.
*/
protected Config $config;
protected DrushConfig $config;

/**
* Loader.
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Config/DefaultConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 29 additions & 11 deletions src/Config/DefaultDrushConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,48 @@

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.
*
* @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;
}

}
10 changes: 5 additions & 5 deletions tests/packages_alter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
version_dev: 12.x-dev
'*':
version: 13.x
version_dev: 13.x-dev
4 changes: 2 additions & 2 deletions tests/src/CommandsTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions tests/src/Functional/Config/ConfigInitializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand All @@ -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(), [
Expand All @@ -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();

Expand All @@ -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(), [
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 11 additions & 7 deletions tests/src/unit/Robo/Config/ConfigAwareTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down

0 comments on commit a06796b

Please sign in to comment.