function UpdateScriptTest::testSuccessfulMultilingualUpdateFunctionality

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

Tests perfoming updates with update.php in a multilingual environment.

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php, line 602

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testSuccessfulMultilingualUpdateFunctionality() {
  // 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.
  $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
  $this->assertEqual($schema_version, 8001, 'update_script_test schema version is 8001 after updating.');
  // Set the installed schema version to one less than the current update.
  drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
  $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
  $this->assertEqual($schema_version, 8000, '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->assertLinkByHref('/update.php');
  $this->assertNoLinkByHref('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(t('Continue'));
  $this->clickLink(t('Apply pending updates'));
  $this->checkForMetaRefresh();
  $this->assertText('Updates were attempted.');
  $this->assertSession()
    ->linkExists('logged');
  $this->assertSession()
    ->linkExists('Administration pages');
  $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [
    ':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.