only in patch2: unchanged: --- a/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php +++ b/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php @@ -107,4 +107,12 @@ public function testUpdateHookN() { $this->assertResponse('200'); } + /** + * {@inheritdoc} + */ + protected function runUpdates() { + parent::runUpdates(); + $this->fixPreBeta13Schema(); + } + } only in patch2: unchanged: --- a/core/modules/system/src/Tests/Entity/Update/SqlContentEntityStorageSchemaIndexTest.php +++ b/core/modules/system/src/Tests/Entity/Update/SqlContentEntityStorageSchemaIndexTest.php @@ -45,15 +45,15 @@ public function testIndex() { $this->assertFalse(db_index_exists('node_field_data', 'node__id__default_langcode__langcode'), 'Index node__id__default_langcode__langcode does not exist prior to running updates.'); $this->assertFalse(db_index_exists('users_field_data', 'user__id__default_langcode__langcode'), 'Index users__id__default_langcode__langcode does not exist prior to running updates.'); - // Running database updates should automatically update the entity schemata - // to add the indices from https://www.drupal.org/node/2261669. + // Running database updates should update the entity schemata to add the + // indices from https://www.drupal.org/node/2261669. $this->runUpdates(); $this->assertFalse(db_index_exists('node_field_data', 'node__default_langcode'), 'Index node__default_langcode properly removed.'); $this->assertTrue(db_index_exists('node_field_data', 'node__id__default_langcode__langcode'), 'Index node__id__default_langcode__langcode properly created on the node_field_data table.'); $this->assertTrue(db_index_exists('users_field_data', 'user__id__default_langcode__langcode'), 'Index users__id__default_langcode__langcode properly created on the user_field_data table.'); - // Ensure that hook_update_N() implementations were in the expected order - // relative to the entity and field updates. The expected order is: + // Ensure that entity schemata updates were performed in the expected + // order, which is: // 1. Initial Drupal 8.0.0-beta12 installation with no indices. // 2. update_order_test_update_8001() is invoked. // 3. update_order_test_update_8002() is invoked. @@ -61,9 +61,9 @@ public function testIndex() { // the update_order_test_field storage. See update_order_test.module. // 5. update_order_test_update_8002() explicitly applies the updates for // the node entity type indices listed above. - // 6. The remaining entity schema updates are applied automatically after - // all update hook implementations have run, which applies the user - // index update. + // 6. \Drupal\system\Tests\Update\UpdatePathTestBase::fixPreBeta13Schema() + // applies all remaining entity and field updates, which includes the + // user index update. $this->assertTrue(\Drupal::state()->get('update_order_test_update_8001', FALSE), 'Index node__default_langcode still existed during update_order_test_update_8001(), indicating that it ran before the entity type updates.'); // Node updates were run during update_order_test_update_8002(). @@ -79,4 +79,12 @@ public function testIndex() { $this->assertFalse(\Drupal::state()->get('update_order_test_update_8002_user__id__default_langcode__langcode', TRUE)); } + /** + * {@inheritdoc} + */ + protected function runUpdates() { + parent::runUpdates(); + $this->fixPreBeta13Schema(); + } + } only in patch2: unchanged: --- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php @@ -200,6 +200,26 @@ protected function runUpdates() { } /** + * Helper function to fix the schema of pre-beta-13 fixtures. + * + * Between beta-12 and beta-13, some hook_update_N() functions were added, + * with corresponding test coverage, but a beta to beta upgrade path was not + * yet officially supported. After beta-13, automated entity and field + * schema updates were removed in favor of modules explicitly controlling + * which changes to update when. Update tests added after beta-13 should + * start with a beta-13 database fixture, but tests that still use a beta-12 + * fixture can extend the runUpdates() function to invoke this function in + * order to emulate what would have happened in a beta-12 to beta-13 update. + * + * @see \Drupal\block\Tests\Update\BlockContextMappingUpdateTest::runUpdates() + * @see \Drupal\system\Tests\Entity\Update\SqlContentEntityStorageSchemaIndexTest::runUpdates() + * @see https://www.drupal.org/node/2542748 + */ + protected function fixPreBeta13Schema() { + \Drupal::service('entity.definition_update_manager')->applyUpdates(); + } + + /** * {@inheritdoc} */ protected function rebuildAll() { only in patch2: unchanged: --- a/core/modules/system/tests/modules/update_order_test/update_order_test.install +++ b/core/modules/system/tests/modules/update_order_test/update_order_test.install @@ -15,16 +15,14 @@ if (\Drupal::state()->get('update_order_test', FALSE)) { /** - * Runs before entity schema updates. + * Stores whether the node__default_langcode index exists. */ function update_order_test_update_8001() { - // Store whether the node__default_langcode index exists when this hook is - // invoked. \Drupal::state()->set('update_order_test_update_8001', db_index_exists('node_field_data', 'node__default_langcode')); } /** - * Runs before entity schema updates. + * Applies some entity schema updates in a specific order. */ function update_order_test_update_8002() { // Check and store whether the update_order_test field exists when this