diff --git a/package_manager/tests/fixtures/packages_comparison/active/composer.json b/package_manager/tests/fixtures/packages_comparison/active/composer.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/package_manager/tests/fixtures/packages_comparison/active/composer.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/package_manager/tests/fixtures/packages_comparison/active/vendor/composer/installed.json b/package_manager/tests/fixtures/packages_comparison/active/vendor/composer/installed.json deleted file mode 100644 index 2152ef82fb7b941ef772fc6f9138454121a9afd2..0000000000000000000000000000000000000000 --- a/package_manager/tests/fixtures/packages_comparison/active/vendor/composer/installed.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "packages": [ - { - "name": "drupal/existing", - "version": "1.0.0" - }, - { - "name": "drupal/updated", - "version": "1.0.0" - }, - { - "name": "drupal/removed", - "version": "1.0.0" - } - ] -} diff --git a/package_manager/tests/fixtures/packages_comparison/stage/composer.json b/package_manager/tests/fixtures/packages_comparison/stage/composer.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/package_manager/tests/fixtures/packages_comparison/stage/composer.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/package_manager/tests/fixtures/packages_comparison/stage/vendor/composer/installed.json b/package_manager/tests/fixtures/packages_comparison/stage/vendor/composer/installed.json deleted file mode 100644 index 562b5f5601507d472e51461dc66c29549b5c0602..0000000000000000000000000000000000000000 --- a/package_manager/tests/fixtures/packages_comparison/stage/vendor/composer/installed.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "packages": [ - { - "name": "drupal/existing", - "version": "1.0.0" - }, - { - "name": "drupal/updated", - "version": "1.1.0" - }, - { - "name": "drupal/added", - "version": "1.0.0" - } - ] -} diff --git a/package_manager/tests/src/Kernel/ComposerUtilityTest.php b/package_manager/tests/src/Kernel/ComposerUtilityTest.php index 6046c781d59e30a77682dc409f6b81ea7be16623..5433200767efba239712f45ce94535a22daffd83 100644 --- a/package_manager/tests/src/Kernel/ComposerUtilityTest.php +++ b/package_manager/tests/src/Kernel/ComposerUtilityTest.php @@ -43,25 +43,6 @@ class ComposerUtilityTest extends KernelTestBase { $this->assertFileDoesNotExist($dir . '/.htaccess'); } - /** - * @covers ::getPackagesNotIn - * @covers ::getPackagesWithDifferentVersionsIn - */ - public function testPackageComparison(): void { - $fixture_dir = __DIR__ . '/../../fixtures/packages_comparison'; - $active = ComposerUtility::createForDirectory($fixture_dir . '/active'); - $staged = ComposerUtility::createForDirectory($fixture_dir . '/stage'); - - $added = $staged->getPackagesNotIn($active); - $this->assertSame(['drupal/added'], array_keys($added)); - - $removed = $active->getPackagesNotIn($staged); - $this->assertSame(['drupal/removed'], array_keys($removed)); - - $updated = $active->getPackagesWithDifferentVersionsIn($staged); - $this->assertSame(['drupal/updated'], array_keys($updated)); - } - /** * @covers ::getProjectForPackage * diff --git a/package_manager/tests/src/Unit/ComposerUtilityTest.php b/package_manager/tests/src/Unit/ComposerUtilityTest.php index 2f6762fd7ae93e997de8006830e3f3101453dc6e..b81c053503f897cca0b4fd998b6df37b160a0b54 100644 --- a/package_manager/tests/src/Unit/ComposerUtilityTest.php +++ b/package_manager/tests/src/Unit/ComposerUtilityTest.php @@ -52,6 +52,32 @@ class ComposerUtilityTest extends UnitTestCase { $this->assertSame($expected_core_package_names, array_keys($core_packages)); } + /** + * @covers ::getPackagesNotIn + * @covers ::getPackagesWithDifferentVersionsIn + */ + public function testPackageComparison(): void { + $active = $this->mockUtilityWithPackages([ + 'drupal/existing' => '1.0.0', + 'drupal/updated' => '1.0.0', + 'drupal/removed' => '1.0.0', + ]); + $staged = $this->mockUtilityWithPackages([ + 'drupal/existing' => '1.0.0', + 'drupal/updated' => '1.1.0', + 'drupal/added' => '1.0.0', + ]); + + $added = $staged->getPackagesNotIn($active); + $this->assertSame(['drupal/added'], array_keys($added)); + + $removed = $active->getPackagesNotIn($staged); + $this->assertSame(['drupal/removed'], array_keys($removed)); + + $updated = $active->getPackagesWithDifferentVersionsIn($staged); + $this->assertSame(['drupal/updated'], array_keys($updated)); + } + /** * Mocks a ComposerUtility object to return a set of installed packages. *