diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 0816fce..854db9b 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -36,6 +36,7 @@ function testTranslationUI() { $this->doTestBasicTranslation(); $this->doTestTranslationOverview(); + $this->doTestSourceLanguageColumn(); $this->doTestOutdatedStatus(); $this->doTestPublishedStatus(); $this->doTestAuthoringInfo(); @@ -116,6 +117,56 @@ protected function doTestTranslationOverview() { } /** + * Tests that the "Source language" column is shown only when needed. + * + * The "Source language" column should only be shown when an entity has + * translations that derive from at least two source languages. + */ + protected function doTestSourceLanguageColumn() { + // Create a new test entity with original values in the default language. + $default_langcode = $this->langcodes[0]; + $values[$default_langcode] = $this->getNewEntityValues($default_langcode); + $entityId = $this->createEntity($values[$default_langcode], $default_langcode); + $entity = entity_load($this->entityTypeId, $entityId, TRUE); + $this->assertTrue($entity, 'Entity found in the database.'); + $this->drupalGet($entity->getSystemPath()); + $this->assertResponse(200, 'Entity URL is valid.'); + + // If all content is written from scratch in various languages then source + // language column should be hidden. + $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); + $this->assertNoText('Source language', format_string('Source language column correctly hidden.')); + + // Create a number of content translations from scratch, so not based on a + // currently existing entity in a different source language. + $langcode = 'fr'; + $values[$langcode] = $this->getNewEntityValues($langcode); + $content_translation_path = $entity->getSystemPath('drupal:content-translation-overview'); + $path = $langcode . '/' . $content_translation_path . '/add/' . $default_langcode . '/' . $langcode; + $this->drupalPostForm($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction($entity)); + $entity = entity_load($this->entityTypeId, $entityId, TRUE); + + // If at most one translated version of an entity is derived from a version + // of it in another language, then Source language column should be hidden. + $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); + $this->assertNoText('Source language', format_string('Source language column correctly hidden.')); + + // Create a new translation based on another source language. + $langcode = 'it'; + $values[$langcode] = $this->getNewEntityValues($langcode); + $source_langcode = 'fr'; + $path = $langcode . '/' . $content_translation_path . '/add/' . $source_langcode . '/' . $langcode; + $this->drupalPostForm($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction($entity)); + $entity = entity_load($this->entityTypeId, $entityId, TRUE); + + // If two or more translated versions of an entity are derived from any + // version of it in another language, then Source language column should be + // shown. + $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); + $this->assertText('Source language', format_string('Source language column correctly shown.')); + } + + /** * Tests up-to-date status tracking. */ protected function doTestOutdatedStatus() {