3 namespace Drupal\Tests\user\Functional;
5 use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase;
8 * Tests the User Translation UI.
12 class UserTranslationUITest extends ContentTranslationUITestBase {
15 * The user name of the test user.
26 public static $modules = ['language', 'content_translation', 'user', 'views'];
28 protected function setUp() {
29 $this->entityTypeId = 'user';
30 $this->testLanguageSelector = FALSE;
31 $this->name = $this->randomMachineName();
34 \Drupal::entityManager()->getStorage('user')->resetCache();
40 protected function getTranslatorPermissions() {
41 return array_merge(parent::getTranslatorPermissions(), ['administer users']);
47 protected function getNewEntityValues($langcode) {
48 // User name is not translatable hence we use a fixed value.
49 return ['name' => $this->name] + parent::getNewEntityValues($langcode);
55 protected function doTestTranslationEdit() {
56 $storage = $this->container->get('entity_type.manager')
57 ->getStorage($this->entityTypeId);
58 $storage->resetCache([$this->entityId]);
59 $entity = $storage->load($this->entityId);
60 $languages = $this->container->get('language_manager')->getLanguages();
62 foreach ($this->langcodes as $langcode) {
63 // We only want to test the title for non-english translations.
64 if ($langcode != 'en') {
65 $options = ['language' => $languages[$langcode]];
66 $url = $entity->urlInfo('edit-form', $options);
67 $this->drupalGet($url);
69 $title = t('@title [%language translation]', [
70 '@title' => $entity->getTranslation($langcode)->label(),
71 '%language' => $languages[$langcode]->getName(),
73 $this->assertRaw($title);