From a480092f4ff315aa5e7142c6a9f92e5b8fc29492 Mon Sep 17 00:00:00 2001
From: "kunal.sachdev" <kunal.sachdev@3685163.no-reply.drupal.org>
Date: Mon, 18 Oct 2021 14:51:20 +0000
Subject: [PATCH] Issue #3243405 by kunal.sachdev: Add a kernel test of
 UpdateVersionValidator

---
 .../UpdateVersionValidatorTest.php            | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php

diff --git a/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php b/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php
new file mode 100644
index 0000000000..4f78068c43
--- /dev/null
+++ b/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation;
+
+use Drupal\automatic_updates\Validation\ValidationResult;
+use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
+
+/**
+ * @covers \Drupal\automatic_updates\Validator\UpdateVersionValidator
+ *
+ * @group automatic_updates
+ */
+class UpdateVersionValidatorTest extends AutomaticUpdatesKernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = [
+    'automatic_updates',
+    'package_manager',
+  ];
+
+  /**
+   * Tests an update version that is same major & minor version as the current.
+   */
+  public function testNoMajorOrMinorUpdates(): void {
+    $this->assertCheckerResultsFromManager([], TRUE);
+  }
+
+  /**
+   * Tests an update version that is a different major version than the current.
+   */
+  public function testMajorUpdates(): void {
+    $this->setCoreVersion('8.9.1');
+    $result = ValidationResult::createError(['Updating from one major version to another is not supported.']);
+    $this->assertCheckerResultsFromManager([$result], TRUE);
+
+  }
+
+  /**
+   * Tests an update version that is a different minor version than the current.
+   */
+  public function testMinorUpdates(): void {
+    $this->setCoreVersion('9.7.1');
+    $result = ValidationResult::createError(['Updating from one minor version to another is not supported.']);
+    $this->assertCheckerResultsFromManager([$result], TRUE);
+  }
+
+}
-- 
GitLab