function LocaleTranslatedSchemaDefinitionTest::testTranslatedUpdate

Same name and namespace in other branches
  1. 9 core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedUpdate()
  2. 8.9.x core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedUpdate()
  3. 11.x core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedUpdate()

Tests that translations do not affect the update system.

File

core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php, line 76

Class

LocaleTranslatedSchemaDefinitionTest
Adds and configures languages to check field schema definition.

Namespace

Drupal\Tests\locale\Functional

Code

public function testTranslatedUpdate() : void {
  // Visit the update page to collect any strings that may be translatable.
  $user = $this->drupalCreateUser([
    'administer software updates',
  ]);
  $this->drupalLogin($user);
  $update_url = Url::fromRoute('system.db_update')->setAbsolute()
    ->toString();
  // Collect strings from the PHP warning page, if applicable, as well as the
  // main update page.
  $this->drupalGet($update_url, [
    'external' => TRUE,
  ]);
  $this->updateRequirementsProblem();
  /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */
  $stringStorage = \Drupal::service('locale.storage');
  $sources = $stringStorage->getStrings();
  // Translate all source strings found.
  foreach ($sources as $source) {
    $stringStorage->createTranslation([
      'lid' => $source->lid,
      'language' => 'fr',
      'translation' => $this->randomMachineName(100),
    ])
      ->save();
  }
  // Ensure that there are no updates just due to translations. Check for
  // markup and a link instead of specific text because text may be
  // translated.
  $this->drupalGet($update_url . '/selection', [
    'external' => TRUE,
  ]);
  $this->assertSession()
    ->statusMessageExists('status');
  $this->assertSession()
    ->linkByHrefNotExists('fr/update.php/run', 'No link to run updates.');
}

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