function UnpackRecipeTest::testUnpackCommandOnIndirectDevDependencyRecipe
Tests the unpacking a recipe that is an indirect dev dependency.
File
-
core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Unpack/ Functional/ UnpackRecipeTest.php, line 361
Class
- UnpackRecipeTest
- Tests recipe unpacking.
Namespace
Drupal\Tests\Composer\Plugin\Unpack\FunctionalCode
public function testUnpackCommandOnIndirectDevDependencyRecipe() : void {
$root_project_path = $this->fixturesDir . '/composer-root';
// Run composer install and confirm the composer.lock was created.
$this->runComposer('install');
// Disable automatic unpacking as it is the default behavior,
$this->runComposer('config --merge --json extra.drupal-recipe-unpack.on-require false');
$this->runComposer('require --dev fixtures/recipe-b');
// Install a recipe and ensure it is not unpacked.
$this->runComposer('require fixtures/recipe-a');
$root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
$this->assertArrayHasKey('fixtures/recipe-a', $root_composer_json['require']);
$this->assertArrayHasKey('fixtures/recipe-b', $root_composer_json['require-dev']);
// Ensure the resulting Composer files are valid.
$this->runComposer('validate');
$this->runComposer('drupal:recipe-unpack fixtures/recipe-a');
$root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
// Ensure recipe A's dependencies are in require.
$this->assertArrayNotHasKey('fixtures/recipe-a', $root_composer_json['require']);
$this->assertArrayHasKey('fixtures/module-b', $root_composer_json['require']);
$this->assertArrayHasKey('fixtures/module-a', $root_composer_json['require']);
$this->assertArrayHasKey('fixtures/theme-a', $root_composer_json['require']);
// Ensure recipe B is still in require-dev even though all it's dependencies
// have been unpacked to require due to unpacking recipe A.
$this->assertSame([
'fixtures/recipe-b',
], array_keys($root_composer_json['require-dev']));
// Ensure recipe B is still list in installed.json.
$installed_json = $this->getFileContents($root_project_path . '/vendor/composer/installed.json');
$installed_packages = array_column($installed_json['packages'], 'name');
$this->assertContains('fixtures/recipe-b', $installed_packages);
$this->assertContains('fixtures/recipe-b', $installed_json['dev-package-names']);
// Ensure the resulting Composer files are valid.
$this->runComposer('validate');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.