function ContentTranslationUITestBase::doTestOutdatedStatus
Same name in this branch
- 8.9.x core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestOutdatedStatus()
Same name in other branches
- 9 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestOutdatedStatus()
- 10 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestOutdatedStatus()
- 11.x core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestOutdatedStatus()
Tests up-to-date status tracking.
1 call to ContentTranslationUITestBase::doTestOutdatedStatus()
- ContentTranslationUITestBase::testTranslationUI in core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationUITestBase.php - Tests the basic translation UI.
File
-
core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationUITestBase.php, line 238
Class
- ContentTranslationUITestBase
- Tests the Content Translation UI.
Namespace
Drupal\Tests\content_translation\FunctionalCode
protected function doTestOutdatedStatus() {
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
$langcode = 'fr';
$languages = \Drupal::languageManager()->getLanguages();
// Mark translations as outdated.
$edit = [
'content_translation[retranslate]' => TRUE,
];
$edit_path = $entity->toUrl('edit-form', [
'language' => $languages[$langcode],
]);
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
// Check that every translation has the correct "outdated" status, and that
// the Translation fieldset is open if the translation is "outdated".
foreach ($this->langcodes as $added_langcode) {
$url = $entity->toUrl('edit-form', [
'language' => ConfigurableLanguage::load($added_langcode),
]);
$this->drupalGet($url);
if ($added_langcode == $langcode) {
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.');
$this->assertEmpty($this->xpath('//details[@id="edit-content-translation" and @open="open"]'), 'The translation tab should be collapsed by default.');
}
else {
$this->assertFieldByXPath('//input[@name="content_translation[outdated]"]', TRUE, 'The translate flag is checked by default.');
$this->assertNotEmpty($this->xpath('//details[@id="edit-content-translation" and @open="open"]'), 'The translation tab is correctly expanded when the translation is outdated.');
$edit = [
'content_translation[outdated]' => FALSE,
];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $added_langcode));
$this->drupalGet($url);
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.');
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
$this->assertFalse($this->manager
->getTranslationMetadata($entity->getTranslation($added_langcode))
->isOutdated(), 'The "outdated" status has been correctly stored.');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.