Skip to content

Commit

Permalink
ACMS-3964: Fixed failing PHPUnit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkhode1 committed Jun 26, 2024
1 parent a901cc7 commit 37ed0b3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
28 changes: 18 additions & 10 deletions src/Config/DefaultDrushConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -17,15 +16,24 @@ class DefaultDrushConfig extends 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"));
parent::__construct();
$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"));
}
$config->set('drush.bin', $config->get("runtime.drush-script"));
$config->setDefault('drush.alias', "self");
parent::__construct($config->export());
$this->set('drush.bin', $config->get("runtime.drush-script"));
$this->setDefault('drush.alias', "self");
$this->combine($config->export());
}

/**
* {@inheritdoc}
*/
public function combine($data) {
$this->getContext(self::PROCESS_CONTEXT)->combine($data);
return $this;
}

}
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
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 37ed0b3

Please sign in to comment.