function FakeSiteFixtureTest::testComposerShow
Tests that Composer show command can be used on the fixture.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ FakeSiteFixtureTest.php, line 121
Class
- FakeSiteFixtureTest
- Test that the 'fake-site' fixture is a valid starting point.
Namespace
Drupal\Tests\package_manager\KernelCode
public function testComposerShow() : void {
$active_dir = $this->container
->get(PathLocator::class)
->getProjectRoot();
(new ActiveFixtureManipulator())->addPackage([
'type' => 'package',
'version' => '1.2.3',
'name' => 'any-org/any-package',
])
->commitChanges();
$process = new Process([
'composer',
'show',
'--format=json',
], $active_dir);
$process->run();
if ($error = $process->getErrorOutput()) {
$this->fail('Process error: ' . $error);
}
$output = json_decode($process->getOutput(), TRUE);
$package_names = array_map(fn(array $package) => $package['name'], $output['installed']);
$this->assertTrue(asort($package_names));
$this->assertSame([
'any-org/any-package',
'drupal/core',
'drupal/core-dev',
'drupal/core-recommended',
], $package_names);
$list = $this->container
->get(ComposerInspector::class)
->getInstalledPackagesList($active_dir);
$list_packages_names = array_keys($list->getArrayCopy());
$this->assertSame([
'any-org/any-package',
'drupal/core',
'drupal/core-dev',
'drupal/core-recommended',
], $list_packages_names);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.