public function ComposerIntegrationTest::testComposerLockHash in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerLockHash()
- 9 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerLockHash()
Tests composer.lock content-hash.
If you have made a change to composer.json, you may need to reconstruct composer.lock. Follow the link below for further instructions.
See also
https://www.drupal.org/about/core/policies/core-dependencies-policies/ma...
File
- core/
tests/ Drupal/ Tests/ ComposerIntegrationTest.php, line 26
Class
- ComposerIntegrationTest
- Tests Composer integration.
Namespace
Drupal\TestsCode
public function testComposerLockHash() {
$content_hash = self::getContentHash(file_get_contents($this->root . '/composer.json'));
$lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
$this
->assertSame($content_hash, $lock['content-hash']);
// @see \Composer\Repository\PathRepository::initialize()
$core_lock_file_hash = '';
$options = [];
foreach ($lock['packages'] as $package) {
if ($package['name'] === 'drupal/core') {
$core_lock_file_hash = $package['dist']['reference'];
$options = $package['transport-options'] ?? [];
break;
}
}
$core_content_hash = sha1(file_get_contents($this->root . '/core/composer.json') . serialize($options));
$this
->assertSame($core_content_hash, $core_lock_file_hash);
}