Skip to content
Snippets Groups Projects

Issue #3254166: Build tests should not modify dependencies' composer.json files

Files
2
@@ -4,12 +4,42 @@ namespace Drupal\Tests\automatic_updates\Build;
use Composer\Json\JsonFile;
use Drupal\BuildTests\QuickStart\QuickStartTestBase;
use Drupal\Composer\Composer;
/**
* Base class for tests which build a test site from a template project.
*/
abstract class TemplateProjectSiteTestBase extends QuickStartTestBase {
/**
* Returns path repository definitions for core's Composer packages.
*
* @param string $group
* The package group. Can be one of 'Template', 'Metapackage', or 'Plugin'.
*
* @return array[]
* A set of path repository definitions, keyed by package name.
*/
protected function getPathRepositories(string $group): array {
/** @var \SplFileInfo[] $files */
$files = Composer::composerSubprojectPaths($this->getDrupalRoot(), $group);
$repositories = [];
foreach ($files as $file) {
$json = new JsonFile($file->getPathname());
$data = $json->read();
$name = $data['name'];
$repositories[$name] = [
'type' => 'path',
'url' => $file->getPath(),
'options' => [
'symlink' => FALSE,
],
];
}
return $repositories;
}
/**
* Creates a Composer repository of all packages installed in vendor.
*
Loading