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