diff --git a/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php b/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4f78068c436fe060fbee2ce27d8907edd59b15a1 --- /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); + } + +}