function UnpackRecipeTest::testRecursiveUnpacking
Tests recursive unpacking.
File
-
core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Unpack/ Functional/ UnpackRecipeTest.php, line 104
Class
- UnpackRecipeTest
- Tests recipe unpacking.
Namespace
Drupal\Tests\Composer\Plugin\Unpack\FunctionalCode
public function testRecursiveUnpacking() : void {
$root_project_path = $this->fixturesDir . '/composer-root';
// Run composer install and confirm the composer.lock was created.
$this->runComposer('config --merge --json sort-packages true');
$this->runComposer('install');
$stdOut = $this->runComposer('require fixtures/recipe-c fixtures/recipe-a');
$this->assertSame("fixtures/recipe-c unpacked.\nfixtures/recipe-a unpacked.\nfixtures/recipe-b unpacked.\n", $stdOut);
$root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
$this->assertSame([
'composer/installers',
'drupal/core-recipe-unpack',
'fixtures/module-a',
'fixtures/module-b',
'fixtures/theme-a',
], array_keys($root_composer_json['require']));
// Ensure the resulting composer files are valid.
$this->runComposer('validate');
// Ensure the recipes exist.
$this->assertFileExists($root_project_path . '/recipes/recipe-a/recipe.yml');
$this->assertFileExists($root_project_path . '/recipes/recipe-b/recipe.yml');
$this->assertFileExists($root_project_path . '/recipes/recipe-c/recipe.yml');
// Ensure the complex constraint has been written correctly.
$this->assertSame('>=2.0.1.0-dev, <3.0.0.0-dev', $root_composer_json['require']['fixtures/module-b']);
// Ensure composer.lock is ordered correctly.
$root_composer_lock = $this->getFileContents($root_project_path . '/composer.lock');
$this->assertSame([
'composer/installers',
'drupal/core-recipe-unpack',
'fixtures/module-a',
'fixtures/module-b',
'fixtures/theme-a',
], array_column($root_composer_lock['packages'], 'name'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.