X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_translation%2Ftests%2Fsrc%2FFunctional%2FContentTranslationUntranslatableFieldsTest.php;fp=web%2Fcore%2Fmodules%2Fcontent_translation%2Ftests%2Fsrc%2FFunctional%2FContentTranslationUntranslatableFieldsTest.php;h=300c17c7ca3d9d5c95cf405c90c8d7ce12b427ab;hp=b44919aa4f18bddb9c4ee26499800b39387e6dd5;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php b/web/core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php index b44919aa4..300c17c7c 100644 --- a/web/core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php +++ b/web/core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\content_translation\Functional; use Drupal\Core\Url; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\language\Entity\ConfigurableLanguage; /** @@ -12,6 +14,11 @@ use Drupal\language\Entity\ConfigurableLanguage; */ class ContentTranslationUntranslatableFieldsTest extends ContentTranslationPendingRevisionTestBase { + /** + * {@inheritdoc} + */ + public static $modules = ['field_test']; + /** * {@inheritdoc} */ @@ -32,6 +39,32 @@ class ContentTranslationUntranslatableFieldsTest extends ContentTranslationPendi $this->assertFalse($definitions[$this->fieldName]->isTranslatable()); } + /** + * {@inheritdoc} + */ + protected function setupTestFields() { + parent::setupTestFields(); + + $field_storage = FieldStorageConfig::create([ + 'field_name' => 'field_multilingual', + 'type' => 'test_field', + 'entity_type' => $this->entityTypeId, + 'cardinality' => 1, + ]); + $field_storage->save(); + FieldConfig::create([ + 'field_storage' => $field_storage, + 'bundle' => $this->bundle, + 'label' => 'Untranslatable-but-visible test field', + 'translatable' => FALSE, + ])->save(); + entity_get_form_display($this->entityTypeId, $this->bundle, 'default') + ->setComponent('field_multilingual', [ + 'type' => 'test_field_widget_multilingual', + ]) + ->save(); + } + /** * Tests that hiding untranslatable field widgets works correctly. */ @@ -52,6 +85,7 @@ class ContentTranslationUntranslatableFieldsTest extends ContentTranslationPendi $this->assertNotEmpty($this->xpath($field_xpath)); $clue_xpath = '//label[@for="edit-' . strtr($this->fieldName, '_', '-') . '-0-value"]/span[text()="(all languages)"]'; $this->assertEmpty($this->xpath($clue_xpath)); + $this->assertSession()->pageTextContains('Untranslatable-but-visible test field'); // Add a translation and check that the untranslatable field widget is // displayed on the translation and edit forms along with translatability @@ -59,11 +93,12 @@ class ContentTranslationUntranslatableFieldsTest extends ContentTranslationPendi $add_url = Url::fromRoute("entity.{$this->entityTypeId}.content_translation_add", [ $entity->getEntityTypeId() => $entity->id(), 'source' => 'en', - 'target' => 'it' + 'target' => 'it', ]); $this->drupalGet($add_url); $this->assertNotEmpty($this->xpath($field_xpath)); $this->assertNotEmpty($this->xpath($clue_xpath)); + $this->assertSession()->pageTextContains('Untranslatable-but-visible test field'); $this->drupalPostForm(NULL, [], 'Save'); // Check that the widget is displayed along with its clue in the edit form @@ -88,11 +123,13 @@ class ContentTranslationUntranslatableFieldsTest extends ContentTranslationPendi $field_xpath = '//input[@name="' . $this->fieldName . '[0][value]"]'; $this->assertNotEmpty($this->xpath($field_xpath)); $this->assertEmpty($this->xpath($clue_xpath)); + $this->assertSession()->pageTextContains('Untranslatable-but-visible test field'); // Verify no widget is displayed on the non-default language edit form. $this->drupalGet($it_edit_url); $this->assertEmpty($this->xpath($field_xpath)); $this->assertEmpty($this->xpath($clue_xpath)); + $this->assertSession()->pageTextContains('Untranslatable-but-visible test field'); // Verify a warning is displayed. $this->assertSession()->pageTextContains('Fields that apply to all languages are hidden to avoid conflicting changes.');