Skip to content
Snippets Groups Projects

Issue #3265874: Do not allow apply if active and staged composer locks are identical.

1 file
+ 18
6
Compare changes
  • Side-by-side
  • Inline
@@ -30,10 +30,19 @@ class StagedDatabaseUpdateValidatorTest extends AutomaticUpdatesKernelTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
$this->disableValidators[] = 'automatic_updates.update_version_validator';
$real_drupal_root = $this->getDrupalRoot();
parent::setUp();
TestStage::$stagingRoot = $this->vfsRoot->url();
//TestStage::$stagingRoot = $this->vfsRoot->url();
$this->createTestProject();
$path_locator = $this->container->get('package_manager.path_locator');
$active_directory = $path_locator->getProjectRoot();
@copy("$real_drupal_root/composer.json", "$active_directory/composer.json");
@copy("$real_drupal_root/composer.lock", "$active_directory/composer.lock");
mkdir("$active_directory/vendor/composer", 0777, TRUE);
@copy("$real_drupal_root/vendor/composer/installed.json", "$active_directory/vendor/composer/installed.json");
/** @var \Drupal\Tests\automatic_updates\Kernel\TestCronUpdater $updater */
$updater = $this->container->get('automatic_updates.cron_updater');
$updater->begin(['drupal' => '9.8.2']);
@@ -42,13 +51,14 @@ class StagedDatabaseUpdateValidatorTest extends AutomaticUpdatesKernelTestBase {
$stage_dir = $updater->getStageDirectory();
mkdir($stage_dir);
// To satisfy StagedProjectsValidator, copy the active Composer files into
// the staging area.
$active_dir = $this->getDrupalRoot();
@copy("$active_dir/composer.json", "$stage_dir/composer.json");
@copy("$active_dir/composer.lock", "$stage_dir/composer.lock");
@copy("$real_drupal_root/composer.json", "$stage_dir/composer.json");
@copy("$real_drupal_root/composer.lock", "$stage_dir/composer.lock");
mkdir("$stage_dir/vendor/composer", 0777, TRUE);
@copy("$active_dir/vendor/composer/installed.json", "$stage_dir/vendor/composer/installed.json");
@copy("$real_drupal_root/vendor/composer/installed.json", "$stage_dir/vendor/composer/installed.json");
// Copy the .install and .post_update.php files from every installed module
// into the staging directory.
@@ -56,10 +66,12 @@ class StagedDatabaseUpdateValidatorTest extends AutomaticUpdatesKernelTestBase {
foreach ($module_list as $name => $module) {
$path = $module->getPath();
@mkdir("$stage_dir/$path", 0777, TRUE);
@mkdir("$active_directory/$path", 0777, TRUE);
foreach (static::SUFFIXES as $suffix) {
// If the source file doesn't exist, silence the warning it raises.
@copy("$active_dir/$path/$name.$suffix", "$stage_dir/$path/$name.$suffix");
@copy("$real_drupal_root/$path/$name.$suffix", "$stage_dir/$path/$name.$suffix");
@copy("$real_drupal_root/$path/$name.$suffix", "$active_directory/$path/$name.$suffix");
}
}
}
Loading