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