annotate core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents c2387f117808
children
rev   line source
Chris@16 1 <?php
Chris@16 2
Chris@16 3 namespace Drupal\Tests\locale\Functional;
Chris@16 4
Chris@16 5 use Drupal\Tests\BrowserTestBase;
Chris@16 6
Chris@16 7 /**
Chris@16 8 * Tests installing in a different language with a non-dev version string.
Chris@16 9 *
Chris@16 10 * @group locale
Chris@16 11 */
Chris@16 12 class LocaleNonInteractiveInstallTest extends BrowserTestBase {
Chris@16 13
Chris@16 14 /**
Chris@16 15 * Gets the version string to use in the translation file.
Chris@16 16 *
Chris@16 17 * @return string
Chris@16 18 * The version string to test, for example, '8.0.0' or '8.6.x'.
Chris@16 19 */
Chris@16 20 protected function getVersionStringToTest() {
Chris@16 21 include_once $this->root . '/core/includes/install.core.inc';
Chris@16 22 $version = _install_get_version_info(\Drupal::VERSION);
Chris@16 23 return $version['major'] . '.0.0';
Chris@16 24 }
Chris@16 25
Chris@16 26 /**
Chris@16 27 * {@inheritdoc}
Chris@16 28 */
Chris@16 29 protected function installParameters() {
Chris@16 30 $parameters = parent::installParameters();
Chris@16 31 // Install Drupal in German.
Chris@16 32 $parameters['parameters']['langcode'] = 'de';
Chris@16 33 // Create a po file so we don't attempt to download one from
Chris@16 34 // localize.drupal.org and to have a test translation that will not change.
Chris@16 35 \Drupal::service('file_system')->mkdir($this->publicFilesDirectory . '/translations', NULL, TRUE);
Chris@16 36 $contents = <<<ENDPO
Chris@16 37 msgid ""
Chris@16 38 msgstr ""
Chris@16 39
Chris@16 40 msgid "Enter the password that accompanies your username."
Chris@16 41 msgstr "Geben sie das Passwort für ihren Benutzernamen ein."
Chris@16 42
Chris@16 43 ENDPO;
Chris@16 44 $version = $this->getVersionStringToTest();
Chris@16 45 file_put_contents($this->publicFilesDirectory . "/translations/drupal-{$version}.de.po", $contents);
Chris@16 46 return $parameters;
Chris@16 47 }
Chris@16 48
Chris@16 49 /**
Chris@16 50 * Tests that the expected translated text appears on the login screen.
Chris@16 51 */
Chris@16 52 public function testInstallerTranslations() {
Chris@16 53 $this->drupalGet('user/login');
Chris@16 54 $this->assertSession()->responseContains('Geben sie das Passwort für ihren Benutzernamen ein.');
Chris@16 55 }
Chris@16 56
Chris@16 57 }