Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/tests/src/Functional/UserTranslationUITest.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\user\Functional; | |
4 | |
5 use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase; | |
6 | |
7 /** | |
8 * Tests the User Translation UI. | |
9 * | |
10 * @group user | |
11 */ | |
12 class UserTranslationUITest extends ContentTranslationUITestBase { | |
13 | |
14 /** | |
15 * The user name of the test user. | |
16 * | |
17 * @var string | |
18 */ | |
19 protected $name; | |
20 | |
21 /** | |
22 * Modules to enable. | |
23 * | |
24 * @var array | |
25 */ | |
26 public static $modules = ['language', 'content_translation', 'user', 'views']; | |
27 | |
28 protected function setUp() { | |
29 $this->entityTypeId = 'user'; | |
30 $this->testLanguageSelector = FALSE; | |
31 $this->name = $this->randomMachineName(); | |
32 parent::setUp(); | |
33 | |
34 \Drupal::entityManager()->getStorage('user')->resetCache(); | |
35 } | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 protected function getTranslatorPermissions() { | |
41 return array_merge(parent::getTranslatorPermissions(), ['administer users']); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
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); | |
50 } | |
51 | |
52 /** | |
53 * {@inheritdoc} | |
54 */ | |
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(); | |
61 | |
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); | |
68 | |
69 $title = t('@title [%language translation]', [ | |
70 '@title' => $entity->getTranslation($langcode)->label(), | |
71 '%language' => $languages[$langcode]->getName(), | |
72 ]); | |
73 $this->assertRaw($title); | |
74 } | |
75 } | |
76 } | |
77 | |
78 } |