function PackageManagerFixtureCreator::createFixture
Creates the fixture.
1 call to PackageManagerFixtureCreator::createFixture()
- PackageManagerFixtureCreator.php in core/
scripts/ PackageManagerFixtureCreator.php
File
-
core/
scripts/ PackageManagerFixtureCreator.php, line 35
Class
- PackageManagerFixtureCreator
- Creates fixture at 'core/modules/package_manager/tests/fixtures/fake_site'.
Code
public static function createFixture() : void {
// Copy drupal scaffold file mapping from core/composer.json to
// fixtures' core/composer.json.
$core_composer_json = new JsonFile(static::CORE_ROOT_PATH . '/core/composer.json');
$core_composer_data = $core_composer_json->read();
$fixture_core_composer_file = new JsonFile(static::FIXTURE_PATH . "/../path_repos/drupal--core/composer.json");
$fixture_core_composer_data = $fixture_core_composer_file->read();
$fixture_core_composer_data['extra']['drupal-scaffold']['file-mapping'] = $core_composer_data['extra']['drupal-scaffold']['file-mapping'];
$fixture_core_composer_file->write($fixture_core_composer_data);
$fixture_packages_json = new JsonFile(static::FIXTURE_PATH . '/packages.json');
$fixture_packages_data = $fixture_packages_json->read();
foreach ($fixture_packages_data['packages']['drupal/core'] as &$release) {
$release['extra']['drupal-scaffold']['file-mapping'] = $core_composer_data['extra']['drupal-scaffold']['file-mapping'];
}
$fixture_packages_json->write($fixture_packages_data);
$fs = new Filesystem();
$fs->remove(static::FIXTURE_PATH . "/composer.lock");
// Remove all the vendor folders but leave our 2 test files.
// @see \Drupal\Tests\package_manager\Kernel\PathExcluder\VendorHardeningExcluderTest
self::removeAllExcept(static::FIXTURE_PATH . "/vendor", [
'.htaccess',
'web.config',
]);
self::runComposerCommand([
'install',
]);
static::removeAllExcept(static::FIXTURE_PATH . '/vendor/composer', [
'installed.json',
'installed.php',
]);
$fs->remove(static::FIXTURE_PATH . '/vendor/autoload.php');
print "\nFixture updated.\nRunning phpcbf";
$process = new Process([
'composer',
'phpcbf',
static::FIXTURE_PATH,
], static::CORE_ROOT_PATH);
$process->run();
print "\nFixture created 🎉.";
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.