function UpdatePathLastRemovedTest::testLastRemovedVersion

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathLastRemovedTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathLastRemovedTest::testLastRemovedVersion()
  2. 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathLastRemovedTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathLastRemovedTest::testLastRemovedVersion()
  3. 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathLastRemovedTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathLastRemovedTest::testLastRemovedVersion()

Tests that a module with a too old schema version can not be updated.

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathLastRemovedTest.php, line 57

Class

UpdatePathLastRemovedTest
Tests that modules can define their last removed update function.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testLastRemovedVersion() {
    drupal_set_installed_schema_version('update_test_last_removed', 8000);
    // Access the update page with a schema version that is too old for the test
    // module.
    $this->drupalLogin($this->updateUser);
    $this->drupalGet($this->updateUrl);
    $assert_session = $this->assertSession();
    $assert_session->pageTextContains('Requirements problem');
    $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 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');
    // Set the expected schema version, updates are successful now.
    drupal_set_installed_schema_version('update_test_last_removed', 8002);
    $this->runUpdates();
    $this->assertEquals(8003, drupal_get_installed_schema_version('update_test_last_removed'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.