Skip to content
Snippets Groups Projects

Issue #3318313: Make OverwriteExistingPackagesValidatorTest fixture less

All threads resolved!
1 file
+ 14
13
Compare changes
  • Side-by-side
  • Inline
@@ -33,19 +33,7 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
@@ -33,19 +33,7 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
* managed by Composer.
* managed by Composer.
*
*
* The staging area has four modules: module_1, module_2, module_3, and
* The staging area has four modules: module_1, module_2, module_3, and
* module_5_different_path. All of them are managed by Composer. We expect the
* module_5_different_path. All of them are managed by Composer.
* following outcomes:
*
* - module_1 and module_2 will raise errors because they would overwrite
* non-Composer managed paths in the active directory.
* - module_3 will cause no problems, since it doesn't exist in the active
* directory at all.
* - module_4, which is defined only in the staged installed.json and
* installed.php, will cause an error because its path collides with
* module_1.
* - module_5_different_path will not cause a problem, even though its package
* name is drupal/module_5, because its project name and path in the staging
* area differ from the active directory.
*/
*/
public function testNewPackagesOverwriteExisting(): void {
public function testNewPackagesOverwriteExisting(): void {
$fixtures_dir = __DIR__ . '/../../fixtures/overwrite_existing_validation';
$fixtures_dir = __DIR__ . '/../../fixtures/overwrite_existing_validation';
@@ -54,6 +42,9 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
@@ -54,6 +42,9 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
$stage = $this->createStage();
$stage = $this->createStage();
$stage->create();
$stage->create();
$stage_dir = $stage->getStageDirectory();
$stage_dir = $stage->getStageDirectory();
 
 
// module_1 and module_2 will raise errors because they would overwrite
 
// non-Composer managed paths in the active directory.
$this->addPackage($stage_dir, [
$this->addPackage($stage_dir, [
'name' => 'drupal/module_1',
'name' => 'drupal/module_1',
'version' => '1.3.0',
'version' => '1.3.0',
@@ -66,18 +57,28 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
@@ -66,18 +57,28 @@ class OverwriteExistingPackagesValidatorTest extends PackageManagerKernelTestBas
'type' => 'drupal-module',
'type' => 'drupal-module',
'install_path' => '../../modules/module_2',
'install_path' => '../../modules/module_2',
]);
]);
 
 
// module_3 will cause no problems, since it doesn't exist in the active
 
// directory at all.
$this->addPackage($stage_dir, [
$this->addPackage($stage_dir, [
'name' => 'drupal/module_3',
'name' => 'drupal/module_3',
'version' => '1.3.0',
'version' => '1.3.0',
'type' => 'drupal-module',
'type' => 'drupal-module',
'install_path' => '../../modules/module_3',
'install_path' => '../../modules/module_3',
]);
]);
 
 
// module_4, doesn't exist in the active directory but exists in the staged
 
// directory, will cause an error because its path collides with module_1.
$this->addPackage($stage_dir, [
$this->addPackage($stage_dir, [
'name' => 'drupal/module_4',
'name' => 'drupal/module_4',
'version' => '1.3.0',
'version' => '1.3.0',
'type' => 'drupal-module',
'type' => 'drupal-module',
'install_path' => '../../modules/module_1',
'install_path' => '../../modules/module_1',
]);
]);
 
 
// module_5_different_path will not cause a problem, even though its package
 
// name is drupal/module_5, because its project name and path in the staging
 
// area differ from the active directory.
$this->addPackage($stage_dir, [
$this->addPackage($stage_dir, [
'name' => 'drupal/module_5',
'name' => 'drupal/module_5',
'version' => '1.3.0',
'version' => '1.3.0',
Loading