Issue #3098475 by Berdir, catch, TravisCarden, xjm, benjifisher, alexpott, larowlan, webchick, dww: Add more strict checking of hook_update_last_removed() and better explanation

merge-requests/2419/head
Alex Pott 2020-03-10 22:15:20 +00:00
parent 1b82190349
commit fd11c5a42c
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
4 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
name: 'Update test with update_last_removed implementation' name: 'Update test with hook_update_last_removed() implementation'
type: module type: module
description: 'Support module for update testing.' description: 'Support module for update testing.'
package: Testing package: Testing

View File

@ -2,11 +2,11 @@
/** /**
* @file * @file
* Install, update and uninstall functions for the update_test_invalid_hook module. * Update functions for the update_test_invalid_hook module.
*/ */
/** /**
* Implements hook_update_last_removed() * Implements hook_update_last_removed().
*/ */
function update_test_last_removed_update_last_removed() { function update_test_last_removed_update_last_removed() {
return 8002; return 8002;

View File

@ -47,21 +47,21 @@ class UpdatePathLastRemovedTest extends BrowserTestBase {
} }
/** /**
* Test that a module with a too old schema version can not be updated. * Tests that a module with a too old schema version can not be updated.
*/ */
public function testLastRemovedVersion() { public function testLastRemovedVersion() {
drupal_set_installed_schema_version('update_test_last_removed', 8000); drupal_set_installed_schema_version('update_test_last_removed', 8000);
drupal_set_installed_schema_version('system', 8804); drupal_set_installed_schema_version('system', 8804);
// Access the update page with too old versions for system and the test // Access the update page with a schema version that is too old for system
// module, only the generic core message should be shown. // and the test module, only the generic core message should be shown.
$this->drupalLogin($this->updateUser); $this->drupalLogin($this->updateUser);
$this->drupalGet($this->updateUrl); $this->drupalGet($this->updateUrl);
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
$assert_session->pageTextContains('Requirements problem'); $assert_session->pageTextContains('Requirements problem');
$assert_session->pageTextContains('The version of Drupal you are trying to update from is too old'); $assert_session->pageTextContains('The version of Drupal you are trying to update from is too old');
$assert_session->pageTextContains('Updating to Drupal 9 is only supported from Drupal version 8.8.0 or higher. If you are trying to update from an older version, first update to the latest version of Drupal 8'); $assert_session->pageTextContains('Updating to Drupal 9 is only supported from Drupal version 8.8.0 or higher. If you are trying to update from an older version, first update to the latest version of Drupal 8');
$assert_session->pageTextNotContains('Unsupported schema version: Update test with update_last_removed implementation'); $assert_session->pageTextNotContains('Unsupported schema version: Update test with hook_update_last_removed() implementation');
$assert_session->linkNotExists('Continue'); $assert_session->linkNotExists('Continue');
@ -72,8 +72,8 @@ class UpdatePathLastRemovedTest extends BrowserTestBase {
$assert_session->pageTextNotContains('The version of Drupal you are trying to update from is too old'); $assert_session->pageTextNotContains('The version of Drupal you are trying to update from is too old');
$assert_session->pageTextContains('Unsupported schema version: Update test with update_last_removed implementation'); $assert_session->pageTextContains('Unsupported schema version: Update test with hook_update_last_removed() implementation');
$assert_session->pageTextContains('The installed version of the Update test with update_last_removed implementation module is too old to update. Update to an intermediate version first (last removed version: 8002, installed version: 8000).'); $assert_session->pageTextContains('The installed version of the Update test with hook_update_last_removed() implementation module is too old to update. Update to an intermediate version first (last removed version: 8002, installed version: 8000).');
$assert_session->linkNotExists('Continue'); $assert_session->linkNotExists('Continue');
// Set the expected schema version for the node and test module, updates are // Set the expected schema version for the node and test module, updates are

View File

@ -58,7 +58,8 @@ trait UpdatePathTestTrait {
$this->fail('The update failed with the following message: "' . reset($failure)->getText() . '"'); $this->fail('The update failed with the following message: "' . reset($failure)->getText() . '"');
} }
// Ensure that there are no pending updates. // Ensure that there are no pending updates. Clear the schema version
// static cache first in case it was accessed before running updates.
drupal_get_installed_schema_version(NULL, TRUE); drupal_get_installed_schema_version(NULL, TRUE);
foreach (['update', 'post_update'] as $update_type) { foreach (['update', 'post_update'] as $update_type) {
switch ($update_type) { switch ($update_type) {