function MetapackageUpdateTest::testUpdated
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php \Drupal\Tests\Composer\Generator\MetapackageUpdateTest::testUpdated()
- 10 core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php \Drupal\Tests\Composer\Generator\MetapackageUpdateTest::testUpdated()
- 11.x core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php \Drupal\Tests\Composer\Generator\MetapackageUpdateTest::testUpdated()
Tests to see if the generated metapackages are in sync with composer.lock.
Note that this is not a test of code correctness, but rather it merely confirms if the package builder was used on the most recent set of metapackages.
See BuilderTest.php for a test that checks for code correctness.
Parameters
string $builderClass: The metapackage builder to test.
string $path: The relative path to the metapackage
@dataProvider updatedTestData
File
-
core/
tests/ Drupal/ Tests/ Composer/ Generator/ MetapackageUpdateTest.php, line 56
Class
- MetapackageUpdateTest
- Test to see if the metapackages are up-to-date with the root composer.lock.
Namespace
Drupal\Tests\Composer\GeneratorCode
public function testUpdated($builderClass, $path) {
// Create a DrupalCoreComposer for the System Under Test (current repo)
$repositoryRoot = dirname(__DIR__, 6);
$drupalCoreInfo = DrupalCoreComposer::createFromPath($repositoryRoot);
// Rebuild the metapackage for the composer.json / composer.lock of
// the current repo.
$builder = new $builderClass($drupalCoreInfo);
$generatedJson = $builder->getPackage();
$generatedJson = PackageGenerator::encode($generatedJson);
// Also load the most-recently-generated version of the metapackage.
$loadedJson = file_get_contents("{$repositoryRoot}/{$path}/composer.json");
// The generated json is the "expected", what we think the loaded
// json would contain, if the current patch is generated correctly
// (metapackages updated when composer.lock is updated).
$version = str_replace('.0-dev', '.x-dev', \Drupal::VERSION);
$message = <<<__EOT__
The rebuilt version of {<span class="php-variable">$path</span>} does not match what is in the source tree.
To fix, run:
COMPOSER_ROOT_VERSION={<span class="php-variable">$version</span>} composer update --lock
__EOT__;
$this->assertEquals($generatedJson, $loadedJson, $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.