function UpdateScriptTest::testSuccessfulMultilingualUpdateFunctionality
Same name in other branches
- 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulMultilingualUpdateFunctionality()
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulMultilingualUpdateFunctionality()
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testSuccessfulMultilingualUpdateFunctionality()
Tests performing updates with update.php in a multilingual environment.
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdateScriptTest.php, line 759
Class
- UpdateScriptTest
- Tests the update script access and functionality.
Namespace
Drupal\Tests\system\Functional\UpdateSystemCode
public function testSuccessfulMultilingualUpdateFunctionality() : void {
// Add some custom languages.
foreach ([
'aa',
'bb',
] as $language_code) {
ConfigurableLanguage::create([
'id' => $language_code,
'label' => $this->randomMachineName(),
])
->save();
}
$config = \Drupal::service('config.factory')->getEditable('language.negotiation');
// Ensure path prefix is used to determine the language.
$config->set('url.source', 'path_prefix');
// Ensure that there's a path prefix set for english as well.
$config->set('url.prefixes.en', 'en');
$config->save();
// Reset the static cache to ensure we have the most current setting.
/** @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.');
// Create admin user.
$admin_user = $this->drupalCreateUser([
'administer software updates',
'access administration pages',
'access site reports',
'access site in maintenance mode',
'administer site configuration',
]);
$this->drupalLogin($admin_user);
// Visit status report page and ensure, that link to update.php has no path prefix set.
$this->drupalGet('en/admin/reports/status', [
'external' => TRUE,
]);
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->linkByHrefExists('/update.php');
$this->assertSession()
->linkByHrefNotExists('en/update.php');
// Click through update.php with 'access administration pages' and
// 'access site reports' permissions.
$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.