function DrupalInstalledTest::testDrupalInstalledHash
Tests DrupalInstalled.php hash changes when scaffolding is run.
File
-
core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ DrupalInstalledTest.php, line 60
Class
- DrupalInstalledTest
- Tests DrupalInstalled.php hash changes when scaffolding is run.
Namespace
Drupal\Tests\Composer\Plugin\Scaffold\FunctionalCode
public function testDrupalInstalledHash() : void {
$topLevelProjectDir = 'drupal-installed-fixture';
$sut = $this->fixturesDir . '/' . $topLevelProjectDir;
$this->mustExec("composer install --no-ansi", $sut);
$original_version_hash = sha1_file($sut . '/vendor/drupal/DrupalInstalled.php');
// Require two fixtures and ensure that the DrupalInstalled.php file is
// updated.
$this->mustExec("composer require --no-ansi --no-interaction fixtures/empty-file:dev-main fixtures/scaffold-override-fixture:dev-main", $sut);
$two_fixtures_hash = sha1_file($sut . '/vendor/drupal/DrupalInstalled.php');
$this->assertNotEquals($original_version_hash, $two_fixtures_hash);
// Remove one fixture and ensure the hash is not equal to the original or
// the hash with two fixtures.
$this->mustExec("composer remove --no-ansi --no-interaction fixtures/empty-file", $sut);
$one_fixture_hash = sha1_file($sut . '/vendor/drupal/DrupalInstalled.php');
$this->assertNotEquals($original_version_hash, $one_fixture_hash);
$this->assertNotEquals($two_fixtures_hash, $one_fixture_hash);
// Add the fixture back and ensure the hash is changed and equal to the
// previous hash for two fixtures.
$this->mustExec("composer require --no-ansi --no-interaction fixtures/empty-file:dev-main", $sut);
$this->assertEquals($two_fixtures_hash, sha1_file($sut . '/vendor/drupal/DrupalInstalled.php'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.