Chris@0: save(); Chris@0: $this->config('system.site')->set('default_langcode', 'fr')->save(); Chris@18: Chris@0: // Clear all caches so that the base field definition, its cache in the Chris@0: // entity manager, the t() cache, etc. are all cleared. Chris@0: drupal_flush_all_caches(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that translated field descriptions do not affect the update system. Chris@0: */ Chris@0: public function testTranslatedSchemaDefinition() { Chris@0: /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */ Chris@0: $stringStorage = \Drupal::service('locale.storage'); Chris@0: Chris@0: $source = $stringStorage->createString([ Chris@0: 'source' => 'Revision ID', Chris@0: ])->save(); Chris@0: Chris@0: $stringStorage->createTranslation([ Chris@0: 'lid' => $source->lid, Chris@0: 'language' => 'fr', Chris@0: 'translation' => 'Translated Revision ID', Chris@0: ])->save(); Chris@0: Chris@0: // Ensure that the field is translated when access through the API. Chris@0: $this->assertEqual('Translated Revision ID', \Drupal::entityManager()->getBaseFieldDefinitions('node')['vid']->getLabel()); Chris@0: Chris@0: // Assert there are no updates. Chris@0: $this->assertFalse(\Drupal::service('entity.definition_update_manager')->needsUpdates()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that translations do not affect the update system. Chris@0: */ Chris@0: public function testTranslatedUpdate() { Chris@0: // Visit the update page to collect any strings that may be translatable. Chris@0: $user = $this->drupalCreateUser(['administer software updates']); Chris@0: $this->drupalLogin($user); Chris@0: $update_url = $GLOBALS['base_url'] . '/update.php'; Chris@0: $this->drupalGet($update_url, ['external' => TRUE]); Chris@0: Chris@0: /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */ Chris@0: $stringStorage = \Drupal::service('locale.storage'); Chris@0: $sources = $stringStorage->getStrings(); Chris@0: Chris@0: // Translate all source strings found. Chris@0: foreach ($sources as $source) { Chris@0: $stringStorage->createTranslation([ Chris@0: 'lid' => $source->lid, Chris@0: 'language' => 'fr', Chris@0: 'translation' => $this->randomMachineName(100), Chris@0: ])->save(); Chris@0: } Chris@0: Chris@0: // Ensure that there are no updates just due to translations. Check for Chris@0: // markup and a link instead of specific text because text may be Chris@0: // translated. Chris@0: $this->drupalGet($update_url . '/selection', ['external' => TRUE]); Chris@18: $this->updateRequirementsProblem(); Chris@18: $this->drupalGet($update_url . '/selection', ['external' => TRUE]); Chris@0: $this->assertRaw('messages--status', 'No pending updates.'); Chris@0: $this->assertNoLinkByHref('fr/update.php/run', 'No link to run updates.'); Chris@0: } Chris@0: Chris@0: }