function UnpackRecipeTest::testRecipeNotUnpackedIfInstallIsDeferred

Tests a recipe can be required using --no-install and installed later.

File

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

Class

UnpackRecipeTest
Tests recipe unpacking.

Namespace

Drupal\Tests\Composer\Plugin\Unpack\Functional

Code

public function testRecipeNotUnpackedIfInstallIsDeferred() : void {
    $root_project_path = $this->fixturesDir . '/composer-root';
    $this->runComposer('install');
    // Install a recipe and check it is in `composer.json` but not unpacked or
    // physically installed.
    $stdOut = $this->runComposer('require --verbose --no-install fixtures/recipe-a');
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    $this->assertSame("Recipes are not unpacked when the --no-install option is used.", trim($stdOut));
    $this->assertSame([
        'composer/installers',
        'drupal/core-recipe-unpack',
        'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));
    $this->assertFileDoesNotExist($root_project_path . '/recipes/recipe-a/recipe.yml');
    // After installing dependencies, the recipe should be installed, but still
    // not unpacked.
    $this->runComposer('install');
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    $this->assertSame([
        'composer/installers',
        'drupal/core-recipe-unpack',
        'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));
    $this->assertFileExists($root_project_path . '/recipes/recipe-a/recipe.yml');
    // 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.