function UnpackRecipeTest::testIgnoreRecipe

Tests a recipe can be ignored and not unpacked.

File

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

Class

UnpackRecipeTest
Tests recipe unpacking.

Namespace

Drupal\Tests\Composer\Plugin\Unpack\Functional

Code

public function testIgnoreRecipe() : void {
    $root_project_path = $this->fixturesDir . '/composer-root';
    // Disable automatic unpacking as it is the default behavior,
    $this->runComposer('config --merge --json extra.drupal-recipe-unpack.ignore \'["fixtures/recipe-a"]\'');
    $this->runComposer('install');
    // Install a recipe and ensure it does not get unpacked.
    $stdOut = $this->runComposer('require --verbose fixtures/recipe-a');
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    $this->assertSame("fixtures/recipe-a not unpacked because it is ignored.", trim($stdOut));
    $this->assertSame([
        'composer/installers',
        'drupal/core-recipe-unpack',
        'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));
    // Ensure the resulting Composer files are valid.
    $this->runComposer('validate');
    // Try using the unpack command on an ignored recipe.
    try {
        $this->runComposer('drupal:recipe-unpack fixtures/recipe-a');
        $this->fail('Ignored recipes should not be unpacked.');
    } catch (\RuntimeException $e) {
        $this->assertStringContainsString('fixtures/recipe-a is in the extra.drupal-recipe-unpack.ignore list.', $e->getMessage());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.