Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Tests\Installer; | |
4 | |
5 use Drupal\Core\Serialization\Yaml; | |
6 use Drupal\simpletest\InstallerTestBase; | |
7 | |
8 /** | |
9 * Tests distribution profile support. | |
10 * | |
11 * @group Installer | |
12 * | |
13 * @see \Drupal\system\Tests\Installer\DistributionProfileTest | |
14 */ | |
15 class DistributionProfileTranslationTest extends InstallerTestBase { | |
16 | |
17 /** | |
18 * {@inheritdoc} | |
19 */ | |
20 protected $langcode = 'de'; | |
21 | |
22 /** | |
23 * The distribution profile info. | |
24 * | |
25 * @var array | |
26 */ | |
27 protected $info; | |
28 | |
29 /** | |
30 * {@inheritdoc} | |
31 */ | |
32 protected function setUp() { | |
33 $this->info = [ | |
34 'type' => 'profile', | |
35 'core' => \Drupal::CORE_COMPATIBILITY, | |
36 'name' => 'Distribution profile', | |
37 'distribution' => [ | |
38 'name' => 'My Distribution', | |
39 'langcode' => $this->langcode, | |
40 'install' => [ | |
41 'theme' => 'bartik', | |
42 ], | |
43 ], | |
44 ]; | |
45 // File API functions are not available yet. | |
46 $path = $this->siteDirectory . '/profiles/mydistro'; | |
47 mkdir($path, 0777, TRUE); | |
48 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info)); | |
49 | |
50 parent::setUp(); | |
51 } | |
52 | |
53 /** | |
54 * {@inheritdoc} | |
55 */ | |
56 protected function visitInstaller() { | |
57 // Place a custom local translation in the translations directory. | |
58 mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); | |
59 file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de')); | |
60 | |
61 parent::visitInstaller(); | |
62 | |
63 // The language should have been automatically detected, all following | |
64 // screens should be translated already. | |
65 $elements = $this->xpath('//input[@type="submit"]/@value'); | |
66 $this->assertEqual((string) current($elements), 'Save and continue de'); | |
67 $this->translations['Save and continue'] = 'Save and continue de'; | |
68 | |
69 // Check the language direction. | |
70 $direction = (string) current($this->xpath('/html/@dir')); | |
71 $this->assertEqual($direction, 'ltr'); | |
72 | |
73 // Verify that the distribution name appears. | |
74 $this->assertRaw($this->info['distribution']['name']); | |
75 // Verify that the requested theme is used. | |
76 $this->assertRaw($this->info['distribution']['install']['theme']); | |
77 // Verify that the "Choose profile" step does not appear. | |
78 $this->assertNoText('profile'); | |
79 } | |
80 | |
81 /** | |
82 * {@inheritdoc} | |
83 */ | |
84 protected function setUpLanguage() { | |
85 // This step is skipped, because the distribution profile uses a fixed | |
86 // language. | |
87 } | |
88 | |
89 /** | |
90 * {@inheritdoc} | |
91 */ | |
92 protected function setUpProfile() { | |
93 // This step is skipped, because there is a distribution profile. | |
94 } | |
95 | |
96 /** | |
97 * Confirms that the installation succeeded. | |
98 */ | |
99 public function testInstalled() { | |
100 $this->assertUrl('user/1'); | |
101 $this->assertResponse(200); | |
102 | |
103 // Confirm that we are logged-in after installation. | |
104 $this->assertText($this->rootUser->getDisplayName()); | |
105 | |
106 // Verify German was configured but not English. | |
107 $this->drupalGet('admin/config/regional/language'); | |
108 $this->assertText('German'); | |
109 $this->assertNoText('English'); | |
110 } | |
111 | |
112 /** | |
113 * Returns the string for the test .po file. | |
114 * | |
115 * @param string $langcode | |
116 * The language code. | |
117 * @return string | |
118 * Contents for the test .po file. | |
119 */ | |
120 protected function getPo($langcode) { | |
121 return <<<ENDPO | |
122 msgid "" | |
123 msgstr "" | |
124 | |
125 msgid "Save and continue" | |
126 msgstr "Save and continue $langcode" | |
127 ENDPO; | |
128 } | |
129 | |
130 } |