function FixtureManipulatorTest::testRemovePackage
@covers ::removePackage
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ FixtureManipulatorTest.php, line 177
Class
- FixtureManipulatorTest
- @coversDefaultClass \Drupal\fixture_manipulator\FixtureManipulator
Namespace
Drupal\Tests\package_manager\KernelCode
public function testRemovePackage() : void {
// We should not be able to remove a package that's not installed.
try {
(new ActiveFixtureManipulator())->removePackage('junk/drawer')
->commitChanges();
$this->fail('Removing a non-existent package should raise an error.');
} catch (\LogicException $e) {
$this->assertStringContainsString('junk/drawer is not required in your composer.json and has not been remove', $e->getMessage());
}
// Remove the 2 packages that were added in ::setUp().
(new ActiveFixtureManipulator())->removePackage('my/package')
->removePackage('my/dev-package', TRUE)
->commitChanges();
$expected_packages = $this->originalFixturePackages
->getArrayCopy();
unset($expected_packages['my/package'], $expected_packages['my/dev-package']);
$expected_list = new InstalledPackagesList($expected_packages);
$this->assertPackageListsEqual($expected_list, $this->inspector
->getInstalledPackagesList($this->dir));
$root_info = $this->inspector
->getRootPackageInfo($this->dir);
$this->assertSame([
'drupal/core-dev',
], array_keys($root_info['devRequires']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.