Skip to content

Commit

Permalink
Remove dead code and re-enbale --partial test. (#5036)
Browse files Browse the repository at this point in the history
* Remove dead code and re-enbale --partial test.

* Remove conditional
  • Loading branch information
weitzman committed Jan 19, 2022
1 parent a7e69ec commit f9faeb6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 53 deletions.
35 changes: 0 additions & 35 deletions src/Commands/core/SiteInstallCommands.php
Expand Up @@ -2,7 +2,6 @@

namespace Drush\Commands\core;

use Composer\Semver\Comparator;
use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\Database\Database;
Expand Down Expand Up @@ -173,13 +172,6 @@ public function taskCallback($install_state): void

protected function determineProfile($profile, $options, $class_loader)
{
// --config-dir fails with Standard profile and any other one that carries content entities.
// Force to minimal install profile only for drupal < 8.6.
if ($options['config-dir'] && Comparator::lessThan(self::getVersion(), '8.6')) {
$this->logger()->info(dt("Using 'minimal' install profile since --config-dir option was provided."));
$profile = 'minimal';
}

// Try to get profile from existing config if not provided as an argument.
// @todo Arguably Drupal core [$boot->getKernel()->getInstallProfile()] could do this - https://github.com/drupal/drupal/blob/8.6.x/core/lib/Drupal/Core/DrupalKernel.php#L1606 reads from DB storage but not file storage.
if (empty($profile) && $options['existing-config']) {
Expand Down Expand Up @@ -224,27 +216,6 @@ protected function determineProfile($profile, $options, $class_loader)
return $profile;
}

/**
* Post installation, run the configuration import.
*
* @hook post-command site-install
*/
public function post($result, CommandData $commandData): void
{
if ($config = $commandData->input()->getOption('config-dir') && Comparator::lessThan(self::getVersion(), '8.6')) {
// Set the destination site UUID to match the source UUID, to bypass a core fail-safe.
$source_storage = new FileStorage($config);
$options = array_merge(Drush::redispatchOptions(), ['yes' => true, 'strict' => 0]);
$selfRecord = $this->siteAliasManager()->getSelf();

$process = $this->processManager()->drush($selfRecord, 'config-set', ['system.site', 'uuid', $source_storage->read('system.site')['uuid']], $options);
$process->mustRun();

$process = $this->processManager()->drush($selfRecord, 'config-import', [], ['source' => $config] + $options);
$process->mustRun($process->showRealtime());
}
}

/**
* Check to see if there are any .yml files in the provided config directory.
*/
Expand Down Expand Up @@ -440,12 +411,6 @@ protected function getSitesSubdirFromUri($root, $uri)
return false;
}

public static function getVersion(): ?string
{
$drupal_root = Drush::bootstrapManager()->getRoot();
return Drush::bootstrap()->getVersion($drupal_root);
}

/**
* Fake the necessary HTTP headers that the Drupal installer still needs:
* @see https://github.com/drupal/drupal/blob/d260101f1ea8a6970df88d2f1899248985c499fc/core/includes/install.core.inc#L287
Expand Down
19 changes: 7 additions & 12 deletions tests/functional/ConfigTest.php
Expand Up @@ -100,20 +100,15 @@ public function testConfigExportImportStatusExistingConfig()
// Test the --existing-config option for site:install.
$this->drush('core:status', [], ['field' => 'drupal-version']);
$drupal_version = $this->getOutputRaw();
if (Comparator::greaterThanOrEqualTo($drupal_version, '8.6')) {
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish existing', $contents);
file_put_contents($system_site_yml, $contents);
$this->installDrupal('dev', true, ['existing-config' => true], false);
$this->drush('config-get', ['system.site', 'page'], ['format' => 'json']);
$page = $this->getOutputFromJSON('system.site:page');
$this->assertStringContainsString('unish existing', $page['front'], 'Existing config was successfully imported during site:install.');
}
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish existing', $contents);
file_put_contents($system_site_yml, $contents);
$this->installDrupal('dev', true, ['existing-config' => true], false);
$this->drush('config-get', ['system.site', 'page'], ['format' => 'json']);
$page = $this->getOutputFromJSON('system.site:page');
$this->assertStringContainsString('unish existing', $page['front'], 'Existing config was successfully imported during site:install.');

// Similar, but this time via --partial option.
if ($this->isDrupalGreaterThanOrEqualTo('8.8.0')) {
$this->markTestSkipped('Partial config import not yet working on 8.8.0');
}
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish partial', $contents);
$partial_path = self::getSandbox() . '/partial';
Expand Down
6 changes: 0 additions & 6 deletions tests/functional/PmEnDisUnListInfoTest.php
Expand Up @@ -47,13 +47,7 @@ public function testEnDisUnList()
$drupal_version = $this->getOutputRaw();

// Test the testing install profile theme is installed.
// Since Drupal 8.8, stark is the default testing theme.
// https://www.drupal.org/node/3083055.
// TODO: Replace once Drupal 8.7 is no longer supported.
$active_theme = 'stark';
if (Comparator::lessThan($drupal_version, '8.8')) {
$active_theme = 'classy';
}
$this->assertStringContainsString($active_theme, $out, 'Themes are in the pm-list');

// Test cache was cleared after enabling a module.
Expand Down

0 comments on commit f9faeb6

Please sign in to comment.