function FakeSiteFixtureTest::testCallToRemovePackage

Tests if `removePackage` can be called on all packages in the fixture.

@covers \Drupal\fixture_manipulator\FixtureManipulator::removePackage

File

core/modules/package_manager/tests/src/Kernel/FakeSiteFixtureTest.php, line 69

Class

FakeSiteFixtureTest
Test that the 'fake-site' fixture is a valid starting point.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testCallToRemovePackage() : void {
    
    /** @var \Drupal\package_manager\ComposerInspector $inspector */
    $inspector = $this->container
        ->get(ComposerInspector::class);
    $active_dir = $this->container
        ->get(PathLocator::class)
        ->getProjectRoot();
    $expected_packages = self::getExpectedFakeSitePackages();
    $actual_packages = array_keys($inspector->getInstalledPackagesList($active_dir)
        ->getArrayCopy());
    sort($actual_packages);
    $this->assertSame($expected_packages, $actual_packages);
    foreach (self::getExpectedFakeSitePackages() as $package_name) {
        (new ActiveFixtureManipulator())->removePackage($package_name, $package_name === 'drupal/core-dev')
            ->commitChanges();
        array_shift($expected_packages);
        $actual_package_names = array_keys($inspector->getInstalledPackagesList($active_dir)
            ->getArrayCopy());
        sort($actual_package_names);
        $this->assertSame($expected_packages, $actual_package_names);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.