Skip to content
Snippets Groups Projects

Issue #3230507: Create build tests for case where site is using core recommended Composer project

Merged Issue #3230507: Create build tests for case where site is using core recommended Composer project
1 unresolved thread
1 unresolved thread
3 files
+ 157
21
Compare changes
  • Side-by-side
  • Inline
Files
3
<?php
namespace Drupal\Tests\automatic_updates\Build;
/**
* Tests an end-to-end core update via the core-recommended metapackage.
*
* @group automatic_updates
*/
class AttendedCoreRecommendedUpdateTest extends AttendedCoreUpdateTest {
/**
* {@inheritdoc}
*/
protected $docRoot = 'docroot/';
/**
* {@inheritdoc}
*/
protected function prepareForUpdate(string $version): void {
parent::prepareForUpdate($version);
$composer = $this->getWorkspaceDirectory() . "/composer.json";
$data = $this->readJson($composer);
$data['repositories']['drupal/core-recommended'] = [
'type' => 'path',
'url' => $this->createTargetMetapackage($version),
'options' => [
'symlink' => FALSE,
],
];
$this->writeJson($composer, $data);
}
/**
* {@inheritdoc}
*/
public function test(): void {
$this->markTestSkipped('This test is disabled until automatic_updates supports drupal/core-recommended.');
}
/**
* Creates a mocked version of drupal/core-recommended to update to.
*
* @param string $version
* The version of the mocked metapackage.
*
* @return string
* The path of the mocked package.
*/
protected function createTargetMetapackage(string $version): string {
$destination = $this->mockPackage($this->getDrupalRoot() . '/composer/Metapackage/CoreRecommended');
$composer = $destination . '/composer.json';
$data = $this->readJson($composer);
$data['version'] = $version;
$data['require']['drupal/core'] = $version;
$this->writeJson($composer, $data);
return $destination;
}
/**
* {@inheritdoc}
*/
protected function getComposerConfiguration(): array {
$configuration = parent::getComposerConfiguration();
$require = &$configuration['require'];
$require['drupal/core-recommended'] = $require['drupal/core'];
unset($require['drupal/core']);
return $configuration;
}
}
Loading