function UnpackRecipeTest::doTestRecipeAUnpacked

Tests Recipe A is unpacked correctly.

Parameters

string $root_project_path: Path to the composer project under test.

string $stdout: The standard out from the composer command unpacks the recipe.

4 calls to UnpackRecipeTest::doTestRecipeAUnpacked()
UnpackRecipeTest::testAutomaticUnpack in core/tests/Drupal/Tests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php
Tests the dependencies unpack on install.
UnpackRecipeTest::testComposerCreateProject in core/tests/Drupal/Tests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php
Tests that recipes are unpacked when using `composer create-project`.
UnpackRecipeTest::testUnpackCommand in core/tests/Drupal/Tests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php
Tests dependency unpacking using drupal:recipe-unpack.
UnpackRecipeTest::testUnpackCommandOnDevRecipe in core/tests/Drupal/Tests/Composer/Plugin/Unpack/Functional/UnpackRecipeTest.php
Tests unpacking a recipe in require-dev using drupal:recipe-unpack.

File

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

Class

UnpackRecipeTest
Tests recipe unpacking.

Namespace

Drupal\Tests\Composer\Plugin\Unpack\Functional

Code

private function doTestRecipeAUnpacked(string $root_project_path, string $stdout) : void {
  $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
  // @see core/tests/Drupal/Tests/Composer/Plugin/Unpack/fixtures/recipes/composer-recipe-a/composer.json
  // @see core/tests/Drupal/Tests/Composer/Plugin/Unpack/fixtures/recipes/composer-recipe-b/composer.json
  $expected_unpacked = [
    'fixtures/recipe-a' => [
      'fixtures/module-b',
    ],
    'fixtures/recipe-b' => [
      'fixtures/module-a',
      'fixtures/theme-a',
    ],
  ];
  foreach ($expected_unpacked as $package => $dependencies) {
    // When the package is unpacked, the unpacked dependencies should be logged
    // in the stdout.
    $this->assertStringContainsString("{$package} unpacked.", $stdout);
    // After being unpacked, the package should be removed from the root
    // composer.json and composer.lock.
    $this->assertArrayNotHasKey($package, $root_composer_json['require']);
    foreach ($dependencies as $dependency) {
      // The package dependencies should be in the root composer.json.
      $this->assertArrayHasKey($dependency, $root_composer_json['require']);
    }
  }
  // Ensure the resulting Composer files are valid.
  $this->runComposer('validate', $root_project_path);
  // The dev dependency has moved.
  $this->assertArrayNotHasKey('require-dev', $root_composer_json);
  // Ensure recipe files exist.
  $this->assertFileExists($root_project_path . '/recipes/recipe-a/recipe.yml');
  $this->assertFileExists($root_project_path . '/recipes/recipe-b/recipe.yml');
  // 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.