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
Compare and
7 files
+ 307
81
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -3,9 +3,9 @@
@@ -3,9 +3,9 @@
namespace Drupal\automatic_updates\Event;
namespace Drupal\automatic_updates\Event;
use Drupal\automatic_updates\AutomaticUpdatesEvents;
use Drupal\automatic_updates\AutomaticUpdatesEvents;
 
use Drupal\automatic_updates\Updater;
use Drupal\automatic_updates\Validation\ValidationResult;
use Drupal\automatic_updates\Validation\ValidationResult;
use Drupal\Core\Extension\ExtensionVersion;
use Drupal\Core\Extension\ExtensionVersion;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -16,15 +16,21 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
@@ -16,15 +16,21 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
use StringTranslationTrait;
use StringTranslationTrait;
 
/**
 
* The updater service.
 
*
 
* @var \Drupal\automatic_updates\Updater
 
*/
 
protected $updater;
 
/**
/**
* Constructs an UpdateVersionSubscriber.
* Constructs an UpdateVersionSubscriber.
*
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* @param \Drupal\automatic_updates\Updater $updater
* The module handler service.
* The updater service.
*/
*/
public function __construct(ModuleHandlerInterface $module_handler) {
public function __construct(Updater $updater) {
// Load procedural functions needed for ::getCoreVersion().
$this->updater = $updater;
$module_handler->loadInclude('update', 'inc', 'update.compare');
}
}
/**
/**
@@ -34,7 +40,11 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
@@ -34,7 +40,11 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
* The running core version as known to the Update module.
* The running core version as known to the Update module.
*/
*/
protected function getCoreVersion(): string {
protected function getCoreVersion(): string {
$available_updates = update_calculate_project_data(update_get_available());
// We need to call these functions separately, because
 
// update_get_available() will include the file that contains
 
// update_calculate_project_data().
 
$available_updates = update_get_available();
 
$available_updates = update_calculate_project_data($available_updates);
return $available_updates['drupal']['existing_version'];
return $available_updates['drupal']['existing_version'];
}
}
@@ -46,7 +56,8 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
@@ -46,7 +56,8 @@ class UpdateVersionSubscriber implements EventSubscriberInterface {
*/
*/
public function checkUpdateVersion(PreStartEvent $event): void {
public function checkUpdateVersion(PreStartEvent $event): void {
$from_version = ExtensionVersion::createFromVersionString($this->getCoreVersion());
$from_version = ExtensionVersion::createFromVersionString($this->getCoreVersion());
$to_version = ExtensionVersion::createFromVersionString($event->getPackageVersions()['drupal/core']);
$core_package_name = $this->updater->getCorePackageName();
 
$to_version = ExtensionVersion::createFromVersionString($event->getPackageVersions()[$core_package_name]);
if ($from_version->getMajorVersion() !== $to_version->getMajorVersion()) {
if ($from_version->getMajorVersion() !== $to_version->getMajorVersion()) {
$error = ValidationResult::createError([
$error = ValidationResult::createError([
Loading