function UnpackRecipeTest::testUnpackCommandWithMultipleRecipes

Tests dependency unpacking using drupal:recipe-unpack with multiple args.

File

core/tests/Drupal/Tests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php, line 245

Class

UnpackRecipeTest
Tests recipe unpacking.

Namespace

Drupal\Tests\Composer\Plugin\Unpack\Functional

Code

public function testUnpackCommandWithMultipleRecipes() : void {
    $root_project_path = $this->fixturesDir . '/composer-root';
    $this->runComposer('install');
    // Disable automatic unpacking as it is the default behavior,
    $this->runComposer('config --merge --json extra.drupal-recipe-unpack.on-require false');
    // Install a recipe and check it is not unpacked.
    $stdOut = $this->runComposer('require fixtures/recipe-a fixtures/recipe-d');
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    // When the package is unpacked, the unpacked dependencies should be logged
    // in the stdout.
    $this->assertStringNotContainsString("unpacked.", $stdOut);
    $this->assertArrayHasKey('fixtures/recipe-a', $root_composer_json['require']);
    $this->assertArrayHasKey('fixtures/recipe-d', $root_composer_json['require']);
    $stdOut = $this->runComposer('drupal:recipe-unpack fixtures/recipe-a fixtures/recipe-d');
    $this->assertStringContainsString("fixtures/recipe-a unpacked.", $stdOut);
    $this->assertStringContainsString("fixtures/recipe-d unpacked.", $stdOut);
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    $this->assertArrayNotHasKey('fixtures/recipe-a', $root_composer_json['require']);
    $this->assertArrayNotHasKey('fixtures/recipe-d', $root_composer_json['require']);
    // 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.