function EquivalentUpdateTest::testModuleUninstall

Same name in other branches
  1. 11.x core/modules/system/tests/src/Functional/UpdateSystem/EquivalentUpdateTest.php \Drupal\Tests\system\Functional\UpdateSystem\EquivalentUpdateTest::testModuleUninstall()

Tests that module uninstall removes skipped update information.

File

core/modules/system/tests/src/Functional/UpdateSystem/EquivalentUpdateTest.php, line 205

Class

EquivalentUpdateTest
Tests that update hooks are properly run.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testModuleUninstall() {
    
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');
    // Verify that the 100000 schema is in place due to
    // equivalent_update_test_update_last_removed().
    $this->assertEquals(100000, $update_registry->getInstalledVersion('equivalent_update_test'));
    // Set the first update to run.
    \Drupal::state()->set('equivalent_update_test_update_100002', TRUE);
    $this->drupalLogin($this->user);
    $this->drupalGet($this->updateUrl, [
        'external' => TRUE,
    ]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    $this->assertSession()
        ->pageTextContains('Schema version 100002.');
    // Run the update hooks.
    $this->clickLink('Apply pending updates');
    $this->checkForMetaRefresh();
    // Ensure that the schema has changed.
    $this->resetAll();
    
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');
    $this->assertEquals(100002, $update_registry->getInstalledVersion('equivalent_update_test'));
    $this->assertSame(100002, $update_registry->getEquivalentUpdate('equivalent_update_test', 100101)->ran_update);
    \Drupal::service('module_installer')->uninstall([
        'equivalent_update_test',
    ]);
    $this->assertNull($update_registry->getEquivalentUpdate('equivalent_update_test', 100101));
    $this->assertEmpty($update_registry->getAllEquivalentUpdates());
}

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