X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fuser%2Ftests%2Fsrc%2FFunctional%2FUserTranslationUITest.php;fp=web%2Fcore%2Fmodules%2Fuser%2Ftests%2Fsrc%2FFunctional%2FUserTranslationUITest.php;h=ae541da83e603f6c8b43b08dee41239bb3e6a589;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/web/core/modules/user/tests/src/Functional/UserTranslationUITest.php b/web/core/modules/user/tests/src/Functional/UserTranslationUITest.php new file mode 100644 index 000000000..ae541da83 --- /dev/null +++ b/web/core/modules/user/tests/src/Functional/UserTranslationUITest.php @@ -0,0 +1,78 @@ +entityTypeId = 'user'; + $this->testLanguageSelector = FALSE; + $this->name = $this->randomMachineName(); + parent::setUp(); + + \Drupal::entityManager()->getStorage('user')->resetCache(); + } + + /** + * {@inheritdoc} + */ + protected function getTranslatorPermissions() { + return array_merge(parent::getTranslatorPermissions(), ['administer users']); + } + + /** + * {@inheritdoc} + */ + protected function getNewEntityValues($langcode) { + // User name is not translatable hence we use a fixed value. + return ['name' => $this->name] + parent::getNewEntityValues($langcode); + } + + /** + * {@inheritdoc} + */ + protected function doTestTranslationEdit() { + $storage = $this->container->get('entity_type.manager') + ->getStorage($this->entityTypeId); + $storage->resetCache([$this->entityId]); + $entity = $storage->load($this->entityId); + $languages = $this->container->get('language_manager')->getLanguages(); + + foreach ($this->langcodes as $langcode) { + // We only want to test the title for non-english translations. + if ($langcode != 'en') { + $options = ['language' => $languages[$langcode]]; + $url = $entity->urlInfo('edit-form', $options); + $this->drupalGet($url); + + $title = t('@title [%language translation]', [ + '@title' => $entity->getTranslation($langcode)->label(), + '%language' => $languages[$langcode]->getName(), + ]); + $this->assertRaw($title); + } + } + } + +}