diff --git a/group.install b/group.install index 11508f0246d85e9f44927802ebb7a72da212d703..d9186e2d811130cda0716c2efd57e423ef1a45f4 100644 --- a/group.install +++ b/group.install @@ -27,9 +27,10 @@ function group_update_10300(&$sandbox) { // Short-circuit the following updates if we are already on version 3. if (empty($group_content_type_configs)) { - \Drupal::state()->set('group_update_10300_detected_version', 3); + \Drupal::state()->set('group_update_10300_detected_legacy_version', FALSE); return; } + \Drupal::state()->set('group_update_10300_detected_legacy_version', TRUE); $table_mapping = \Drupal::entityTypeManager()->getStorage('group_relationship')->getTableMapping(); assert($table_mapping instanceof DefaultTableMapping); @@ -224,7 +225,7 @@ function group_update_10300(&$sandbox) { */ function group_update_10301(&$sandbox) { // Short-circuit the update if we are already on version 3. - if (\Drupal::state()->get('group_update_10300_detected_version', FALSE)) { + if (!\Drupal::state()->get('group_update_10300_detected_legacy_version', FALSE)) { return; } @@ -242,7 +243,7 @@ function group_update_10301(&$sandbox) { */ function group_update_10302(&$sandbox) { // Short-circuit the update if we are already on version 3. - if (\Drupal::state()->get('group_update_10300_detected_version', FALSE)) { + if (!\Drupal::state()->get('group_update_10300_detected_legacy_version', FALSE)) { return; } diff --git a/tests/fixtures/update/group-v-2-3-x.php.gz b/tests/fixtures/update/group-v-2-3-x.php.gz index 628c8be30569155bb24a1eaa5cac0c52253486a4..b76f2210b73c3611711d5dab7ac973d6c695926a 100644 Binary files a/tests/fixtures/update/group-v-2-3-x.php.gz and b/tests/fixtures/update/group-v-2-3-x.php.gz differ diff --git a/tests/src/Functional/Update/Group2to3UpdateTest.php b/tests/src/Functional/Update/Group2to3UpdateTest.php index a8cd96e7ddcc90edd03ae9eec66dabe9e142aa4a..b4ef0a128f1272c07a280339c8b74d1d89d38484 100644 --- a/tests/src/Functional/Update/Group2to3UpdateTest.php +++ b/tests/src/Functional/Update/Group2to3UpdateTest.php @@ -17,17 +17,6 @@ use Drupal\field\FieldStorageConfigInterface; */ class Group2to3UpdateTest extends UpdatePathTestBase { - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - if (version_compare(\Drupal::VERSION, '11', '>=')) { - $this->markTestSkipped('The fixture for the upgrade path was made for Drupal 10.3, skipping test on later versions.'); - } - } - /** * {@inheritdoc} */ @@ -127,6 +116,8 @@ class Group2to3UpdateTest extends UpdatePathTestBase { $this->assertEquals([ 'group.content_type.class-group_membership', 'group.content_type.class-group_node-page', + 'group.content_type.group_content_type_0055e25dd2326', + 'group.content_type.group_content_type_8b9eed1f843e7', ], \Drupal::configFactory()->listAll('group.content_type.')); $this->assertEquals([], \Drupal::configFactory()->listAll('group.relationship_type.')); @@ -136,6 +127,8 @@ class Group2to3UpdateTest extends UpdatePathTestBase { $this->assertEquals([ 'group.relationship_type.class-group_membership', 'group.relationship_type.class-group_node-page', + 'group.relationship_type.group_content_type_0055e25dd2326', + 'group.relationship_type.group_content_type_8b9eed1f843e7', ], \Drupal::configFactory()->listAll('group.relationship_type.')); } @@ -146,6 +139,8 @@ class Group2to3UpdateTest extends UpdatePathTestBase { $this->assertEquals([ 'uuid:000b9028-9efe-4a4f-9552-4ed2343481d5' => ['group.content_type.class-group_node-page'], 'uuid:1891ac47-eae0-4075-b85d-38c7ca8b5122' => ['group.content_type.class-group_membership'], + 'uuid:33a8b55e-dd77-40b2-bd7c-6357e3992814' => ['group.content_type.group_content_type_0055e25dd2326'], + 'uuid:cbac971a-14af-499a-954c-5b52d6493c01' => ['group.content_type.group_content_type_8b9eed1f843e7'], ], \Drupal::keyValue(QueryFactory::CONFIG_LOOKUP_PREFIX . 'group_content_type')->getAll()); $this->assertEquals([], \Drupal::keyValue(QueryFactory::CONFIG_LOOKUP_PREFIX . 'group_relationship_type')->getAll()); @@ -155,6 +150,8 @@ class Group2to3UpdateTest extends UpdatePathTestBase { $this->assertEquals([ 'uuid:000b9028-9efe-4a4f-9552-4ed2343481d5' => ['group.relationship_type.class-group_node-page'], 'uuid:1891ac47-eae0-4075-b85d-38c7ca8b5122' => ['group.relationship_type.class-group_membership'], + 'uuid:33a8b55e-dd77-40b2-bd7c-6357e3992814' => ['group.relationship_type.group_content_type_0055e25dd2326'], + 'uuid:cbac971a-14af-499a-954c-5b52d6493c01' => ['group.relationship_type.group_content_type_8b9eed1f843e7'], ], \Drupal::keyValue(QueryFactory::CONFIG_LOOKUP_PREFIX . 'group_relationship_type')->getAll()); } @@ -223,7 +220,10 @@ class Group2to3UpdateTest extends UpdatePathTestBase { $expected_map = [ 'group_roles' => [ 'type' => 'entity_reference', - 'bundles' => ['class-group_membership' => 'class-group_membership'], + 'bundles' => [ + 'class-group_membership' => 'class-group_membership', + 'group_content_type_0055e25dd2326' => 'group_content_type_0055e25dd2326', + ], ], 'field_short_field' => [ 'type' => 'string', @@ -288,6 +288,15 @@ class Group2to3UpdateTest extends UpdatePathTestBase { } } + /** + * Tests that a state key is set when the legacy version was detected. + */ + public function testLegacyVersionStateEntry() { + $this->assertNull(\Drupal::state()->get('group_update_10300_detected_legacy_version')); + $this->runUpdates(); + $this->assertTrue(\Drupal::state()->get('group_update_10300_detected_legacy_version')); + } + /** * Gets the entity field manager. *