function UnpackRecipeTest::testUnpackCommandWithoutRecipesArgument

Tests dependency unpacking using drupal:recipe-unpack with no arguments.

File

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

Class

UnpackRecipeTest
Tests recipe unpacking.

Namespace

Drupal\Tests\Composer\Plugin\Unpack\Functional

Code

public function testUnpackCommandWithoutRecipesArgument() : void {
  $root_project_path = $this->fixturesDir . '/composer-root';
  $this->runComposer('install');
  // Tests unpack command with no arguments and no recipes in the root
  // composer package.
  $stdOut = $this->runComposer('drupal:recipe-unpack');
  $this->assertSame("No recipes to unpack.\n", $stdOut);
  // 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');
  $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.