function UpdateScriptTest::testSuccessfulUpdateFunctionality
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulUpdateFunctionality()
- 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulUpdateFunctionality()
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulUpdateFunctionality()
Tests update.php after performing a successful update.
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdateScriptTest.php, line 533
Class
- UpdateScriptTest
- Tests the update script access and functionality.
Namespace
Drupal\Tests\system\Functional\UpdateSystemCode
public function testSuccessfulUpdateFunctionality() {
$initial_maintenance_mode = $this->container
->get('state')
->get('system.maintenance_mode');
$this->assertNull($initial_maintenance_mode, 'Site is not in maintenance mode.');
$this->runUpdates($initial_maintenance_mode);
$final_maintenance_mode = $this->container
->get('state')
->get('system.maintenance_mode');
$this->assertEquals($initial_maintenance_mode, $final_maintenance_mode, 'Maintenance mode should not have changed after database updates.');
// Reset the static cache to ensure we have the most current setting.
$this->resetAll();
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
$schema_version = $update_registry->getInstalledVersion('update_script_test');
$this->assertEquals(8001, $schema_version, 'update_script_test schema version is 8001 after updating.');
// Set the installed schema version to one less than the current update.
$update_registry->setInstalledVersion('update_script_test', $schema_version - 1);
$schema_version = $update_registry->getInstalledVersion('update_script_test');
$this->assertEquals(8000, $schema_version, 'update_script_test schema version overridden to 8000.');
// Click through update.php with 'access administration pages' and
// 'access site reports' permissions.
$admin_user = $this->drupalCreateUser([
'administer software updates',
'access administration pages',
'access site reports',
'access site in maintenance mode',
]);
$this->drupalLogin($admin_user);
$this->drupalGet($this->updateUrl, [
'external' => TRUE,
]);
$this->updateRequirementsProblem();
$this->clickLink('Continue');
$this->clickLink('Apply pending updates');
$this->checkForMetaRefresh();
$this->assertSession()
->pageTextContains('Updates were attempted.');
$this->assertSession()
->linkExists('logged');
$this->assertSession()
->linkExists('Administration pages');
$this->assertSession()
->elementNotExists('xpath', '//main//a[contains(@href, "update.php")]');
$this->clickLink('Administration pages');
$this->assertSession()
->statusCodeEquals(200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.