annotate core/modules/system/src/Tests/Installer/InstallerTranslationQueryTest.php @ 12:7a779792577d

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