Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Tests/Installer/InstallerTranslationQueryTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Tests\Installer; | |
4 | |
5 use Drupal\simpletest\InstallerTestBase; | |
6 | |
7 /** | |
8 * Installs Drupal in German and checks resulting site. | |
9 * | |
10 * @group Installer | |
11 * | |
12 * @see \Drupal\system\Tests\Installer\InstallerTranslationTest | |
13 */ | |
14 class InstallerTranslationQueryTest extends InstallerTestBase { | |
15 | |
16 /** | |
17 * Overrides the language code in which to install Drupal. | |
18 * | |
19 * @var string | |
20 */ | |
21 protected $langcode = 'de'; | |
22 | |
23 /** | |
24 * {@inheritdoc} | |
25 */ | |
26 protected function visitInstaller() { | |
27 // Place a custom local translation in the translations directory. | |
28 mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); | |
29 file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de')); | |
30 | |
31 // The unrouted URL assembler does not exist at this point, so we build the | |
32 // URL ourselves. | |
33 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php' . '?langcode=' . $this->langcode); | |
34 | |
35 // The language should have been automatically detected, all following | |
36 // screens should be translated already. | |
37 $elements = $this->xpath('//input[@type="submit"]/@value'); | |
38 $this->assertEqual((string) current($elements), 'Save and continue de'); | |
39 $this->translations['Save and continue'] = 'Save and continue de'; | |
40 | |
41 // Check the language direction. | |
42 $direction = (string) current($this->xpath('/html/@dir')); | |
43 $this->assertEqual($direction, 'ltr'); | |
44 } | |
45 | |
46 /** | |
47 * {@inheritdoc} | |
48 */ | |
49 protected function setUpLanguage() { | |
50 // The language was was preset by passing a query parameter in the URL, so | |
51 // no explicit language selection is necessary. | |
52 } | |
53 | |
54 /** | |
55 * Verifies the expected behaviors of the installation result. | |
56 */ | |
57 public function testInstaller() { | |
58 $this->assertUrl('user/1'); | |
59 $this->assertResponse(200); | |
60 | |
61 // Verify German was configured but not English. | |
62 $this->drupalGet('admin/config/regional/language'); | |
63 $this->assertText('German'); | |
64 $this->assertNoText('English'); | |
65 } | |
66 | |
67 /** | |
68 * Returns the string for the test .po file. | |
69 * | |
70 * @param string $langcode | |
71 * The language code. | |
72 * @return string | |
73 * Contents for the test .po file. | |
74 */ | |
75 protected function getPo($langcode) { | |
76 return <<<ENDPO | |
77 msgid "" | |
78 msgstr "" | |
79 | |
80 msgid "Save and continue" | |
81 msgstr "Save and continue $langcode" | |
82 ENDPO; | |
83 } | |
84 | |
85 } |