diff --git a/core/modules/update/src/ModuleVersionParser.php b/core/modules/update/src/ModuleVersionParser.php index 4ae563a443..6855adc2fa 100644 --- a/core/modules/update/src/ModuleVersionParser.php +++ b/core/modules/update/src/ModuleVersionParser.php @@ -28,7 +28,7 @@ public function __construct($version) { * Constructs a module version parser from a support branch. * * This can be used to determine the major and minor versions. The patch - * version will always be 'x'. + * version will always be NULL. * * @param string $branch * The support branch. @@ -70,7 +70,10 @@ public function getMinorVersion() { public function getPatchVersion() { $version_parts = explode('.', $this->getVersionStringWithoutCoreCompatibility()); $last_version_part = count($version_parts) === 2 ? $version_parts[1] : $version_parts[2]; - return explode('-', $last_version_part)[0]; + $patch = explode('-', $last_version_part)[0]; + // If patch equals 'x' this parser was created from a branch and the patch + // version cannot be determined. + return $patch === 'x' ? NULL : $patch; } /** diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_0.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_0.xml index 8f710f7173..612b84b128 100644 --- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_0.xml +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_0.xml @@ -4,7 +4,6 @@ aaa_update_test Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/aaa_update_test diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.1_8.x-1.2.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.1_8.x-1.2.xml index a29501cec7..9360630e67 100644 --- a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.1_8.x-1.2.xml +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.1_8.x-1.2.xml @@ -4,7 +4,6 @@ aaa_update_test Drupal 8.x - 8.x-1. 8.x-1. published http://example.com/project/aaa_update_test diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2.xml index 42f305fac6..4d0bfdc904 100644 --- a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2.xml +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2.xml @@ -4,7 +4,6 @@ aaa_update_test Drupal 8.x - 8.x-1. 8.x-1. published http://example.com/project/aaa_update_test diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml index 3248bb500b..db37a11c33 100644 --- a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml @@ -4,7 +4,6 @@ aaa_update_test Drupal 8.x - 8.x-2. 8.x-1.,8.x-2. published http://example.com/project/aaa_update_test diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-2.2_1.x_secure.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-2.2_1.x_secure.xml index 403d73d4aa..7852627d71 100644 --- a/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-2.2_1.x_secure.xml +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-2.2_1.x_secure.xml @@ -4,7 +4,6 @@ aaa_update_test Drupal 8.x - 8.x-2. 8.x-1.,8.x-2. published http://example.com/project/aaa_update_test diff --git a/core/modules/update/tests/modules/update_test/bbb_update_test.1_0.xml b/core/modules/update/tests/modules/update_test/bbb_update_test.1_0.xml index 1a537d1563..a5ecedaed0 100644 --- a/core/modules/update/tests/modules/update_test/bbb_update_test.1_0.xml +++ b/core/modules/update/tests/modules/update_test/bbb_update_test.1_0.xml @@ -4,7 +4,6 @@ bbb_update_test Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/bbb_update_test diff --git a/core/modules/update/tests/modules/update_test/ccc_update_test.1_0.xml b/core/modules/update/tests/modules/update_test/ccc_update_test.1_0.xml index ce0d5aafac..b4a2a42985 100644 --- a/core/modules/update/tests/modules/update_test/ccc_update_test.1_0.xml +++ b/core/modules/update/tests/modules/update_test/ccc_update_test.1_0.xml @@ -4,7 +4,6 @@ ccc_update_test Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/ccc_update_test diff --git a/core/modules/update/tests/modules/update_test/drupal.0.0-alpha1.xml b/core/modules/update/tests/modules/update_test/drupal.0.0-alpha1.xml index edb6187884..b22b6eb36d 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.0-alpha1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.0-alpha1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.0.0-beta1.xml b/core/modules/update/tests/modules/update_test/drupal.0.0-beta1.xml index db84144c18..0d27e6a921 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.0-beta1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.0-beta1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.0.0.xml b/core/modules/update/tests/modules/update_test/drupal.0.0.xml index bdf18b2e82..130883c1e1 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.0.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.0.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.0.1-alpha1.xml b/core/modules/update/tests/modules/update_test/drupal.0.1-alpha1.xml index 49c34de7aa..fefea6fcf8 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.1-alpha1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.1-alpha1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.0.1-beta1.xml b/core/modules/update/tests/modules/update_test/drupal.0.1-beta1.xml index 46c1a7e5ab..933a864bd9 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.1-beta1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.1-beta1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.0.1.xml b/core/modules/update/tests/modules/update_test/drupal.0.1.xml index 7231ff0649..ef428accf4 100644 --- a/core/modules/update/tests/modules/update_test/drupal.0.1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.0.1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.0-alpha1.xml b/core/modules/update/tests/modules/update_test/drupal.1.0-alpha1.xml index 4125caed95..00d64ca52e 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.0-alpha1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.0-alpha1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.0-beta1.xml b/core/modules/update/tests/modules/update_test/drupal.1.0-beta1.xml index c46b9453f8..13aad8f6aa 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.0-beta1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.0-beta1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.0.xml b/core/modules/update/tests/modules/update_test/drupal.1.0.xml index f2424638d3..eeadef9474 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.0.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.0.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.1-alpha1.xml b/core/modules/update/tests/modules/update_test/drupal.1.1-alpha1.xml index 3abb7fab44..68e4ac1fb9 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.1-alpha1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.1-alpha1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.1-beta1.xml b/core/modules/update/tests/modules/update_test/drupal.1.1-beta1.xml index 50ae5c77c2..5624974945 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.1-beta1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.1-beta1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.1.1.xml b/core/modules/update/tests/modules/update_test/drupal.1.1.xml index 22fb150713..32c4454571 100644 --- a/core/modules/update/tests/modules/update_test/drupal.1.1.xml +++ b/core/modules/update/tests/modules/update_test/drupal.1.1.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.9.xml b/core/modules/update/tests/modules/update_test/drupal.9.xml index b3f4bd0371..41549ca5ef 100644 --- a/core/modules/update/tests/modules/update_test/drupal.9.xml +++ b/core/modules/update/tests/modules/update_test/drupal.9.xml @@ -4,7 +4,6 @@ drupal Drupal 9.x -9.0. 9.0. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.dev.xml b/core/modules/update/tests/modules/update_test/drupal.dev.xml index b95d34c316..1ddb840f5c 100644 --- a/core/modules/update/tests/modules/update_test/drupal.dev.xml +++ b/core/modules/update/tests/modules/update_test/drupal.dev.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.0.1_0.2.xml b/core/modules/update/tests/modules/update_test/drupal.sec.0.1_0.2.xml index 7aeb360c98..1aa9babbd1 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.0.1_0.2.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.1_0.2.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml index ac3785faef..c986142d29 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1.,8.2. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2.xml b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2.xml index af63215dfb..f597920a56 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1.,8.2. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.0.2.xml b/core/modules/update/tests/modules/update_test/drupal.sec.0.2.xml index 6a6141eb8b..c4919bc69b 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.0.2.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.1.2.xml b/core/modules/update/tests/modules/update_test/drupal.sec.1.2.xml index 7f636e9622..329018531f 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.1.2.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.1.2.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/drupal.sec.1.2_insecure.xml b/core/modules/update/tests/modules/update_test/drupal.sec.1.2_insecure.xml index f45c980180..04cee7d01d 100644 --- a/core/modules/update/tests/modules/update_test/drupal.sec.1.2_insecure.xml +++ b/core/modules/update/tests/modules/update_test/drupal.sec.1.2_insecure.xml @@ -4,7 +4,6 @@ drupal Drupal 8.x -8.0. 8.0.,8.1. published http://example.com/project/drupal diff --git a/core/modules/update/tests/modules/update_test/update_test_basetheme.1_1-sec.xml b/core/modules/update/tests/modules/update_test/update_test_basetheme.1_1-sec.xml index be8e02aa6f..370f68842f 100644 --- a/core/modules/update/tests/modules/update_test/update_test_basetheme.1_1-sec.xml +++ b/core/modules/update/tests/modules/update_test/update_test_basetheme.1_1-sec.xml @@ -4,7 +4,6 @@ update_test_basetheme Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/update_test_basetheme diff --git a/core/modules/update/tests/modules/update_test/update_test_new_module.1_1.xml b/core/modules/update/tests/modules/update_test/update_test_new_module.1_1.xml index 8f07f12e54..6d98f52ea0 100644 --- a/core/modules/update/tests/modules/update_test/update_test_new_module.1_1.xml +++ b/core/modules/update/tests/modules/update_test/update_test_new_module.1_1.xml @@ -4,7 +4,6 @@ update_test_new_module Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/update_test_new_module diff --git a/core/modules/update/tests/modules/update_test/update_test_subtheme.1_0.xml b/core/modules/update/tests/modules/update_test/update_test_subtheme.1_0.xml index 3b1932b537..8909ac6bab 100644 --- a/core/modules/update/tests/modules/update_test/update_test_subtheme.1_0.xml +++ b/core/modules/update/tests/modules/update_test/update_test_subtheme.1_0.xml @@ -4,7 +4,6 @@ update_test_subtheme Drupal 8.x -8.x-1. 8.x-1. published http://example.com/project/update_test_subtheme diff --git a/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php b/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php index 580dd19562..e019a2c443 100644 --- a/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php +++ b/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php @@ -18,8 +18,8 @@ class ModuleVersionParserTest extends UnitTestCase { * @dataProvider providerVersionInfos */ public function testGetMajorVersion($version, $excepted_version_info) { - $releaseInfo = new ModuleVersionParser($version); - $this->assertSame($excepted_version_info['major'], $releaseInfo->getMajorVersion()); + $parser = new ModuleVersionParser($version); + $this->assertSame($excepted_version_info['major'], $parser->getMajorVersion()); } /** @@ -28,8 +28,8 @@ public function testGetMajorVersion($version, $excepted_version_info) { * @dataProvider providerVersionInfos */ public function testGetMinorVersion($version, $excepted_version_info) { - $releaseInfo = new ModuleVersionParser($version); - $this->assertSame($excepted_version_info['minor'], $releaseInfo->getMinorVersion()); + $parser = new ModuleVersionParser($version); + $this->assertSame($excepted_version_info['minor'], $parser->getMinorVersion()); } /** @@ -38,8 +38,8 @@ public function testGetMinorVersion($version, $excepted_version_info) { * @dataProvider providerVersionInfos */ public function testGetPatchVersion($version, $excepted_version_info) { - $releaseInfo = new ModuleVersionParser($version); - $this->assertSame($excepted_version_info['patch'], $releaseInfo->getPatchVersion()); + $parser = new ModuleVersionParser($version); + $this->assertSame($excepted_version_info['patch'], $parser->getPatchVersion()); } /** @@ -48,8 +48,8 @@ public function testGetPatchVersion($version, $excepted_version_info) { * @dataProvider providerVersionInfos */ public function testGetVersionExtra($version, $excepted_version_info) { - $releaseInfo = new ModuleVersionParser($version); - $this->assertSame($excepted_version_info['extra'], $releaseInfo->getVersionExtra()); + $parser = new ModuleVersionParser($version); + $this->assertSame($excepted_version_info['extra'], $parser->getVersionExtra()); } /** @@ -58,8 +58,23 @@ public function testGetVersionExtra($version, $excepted_version_info) { * @dataProvider providerVersionInfos */ public function testGetSupportBranch($version, $excepted_version_info) { - $releaseInfo = new ModuleVersionParser($version); - $this->assertSame($excepted_version_info['branch'], $releaseInfo->getSupportBranch()); + $parser = new ModuleVersionParser($version); + $this->assertSame($excepted_version_info['branch'], $parser->getSupportBranch()); + } + + /** + * @covers ::createFromSupportBranch + * + * @dataProvider providerVersionInfos + */ + public function testCreateFromSupportBranch($version, $excepted_version_info) { + $parser = ModuleVersionParser::createFromSupportBranch($excepted_version_info['branch']); + $this->assertInstanceOf(ModuleVersionParser::class, $parser); + $this->assertSame($excepted_version_info['major'], $parser->getMajorVersion()); + $this->assertSame($excepted_version_info['minor'], $parser->getMinorVersion()); + // Version extra and Patch version can't be determined from a branch. + $this->assertSame(NULL, $parser->getVersionExtra()); + $this->assertSame(NULL, $parser->getPatchVersion()); } /**