LocaleNonInteractiveInstallTest.php

Same filename and directory in other branches
  1. 10 core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
  2. 11.x core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
  3. 9 core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
  4. 8.9.x core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php

Namespace

Drupal\Tests\locale\Functional

File

core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\locale\Functional;

use Drupal\Tests\BrowserTestBase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

/**
 * Tests installing in a different language with a non-dev version string.
 */
class LocaleNonInteractiveInstallTest extends BrowserTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * {@inheritdoc}
   */
  protected function installParameters() : array {
    $parameters = parent::installParameters();
    // Install Drupal in German.
    $parameters['parameters']['langcode'] = 'de';
    // Create a po file so we don't attempt to download one from
    // localize.drupal.org and to have a test translation that will not change.
    \Drupal::service('file_system')->mkdir($this->publicFilesDirectory . '/translations', NULL, TRUE);
    $contents = <<<PO
    msgid ""
    msgstr ""
    
    msgid "Log in"
    msgstr "Anmelden"
    
    PO;
    file_put_contents($this->publicFilesDirectory . '/translations/drupal-' . \Drupal::VERSION . '.de.po', $contents);
    return $parameters;
  }
  
  /**
   * Tests that the expected translated text appears on the login screen.
   */
  public function testInstallerTranslations() : void {
    $this->drupalGet('user/login');
    // cSpell:disable-next-line
    $this->assertSession()
      ->responseContains('Anmelden');
  }

}

Classes

Title Deprecated Summary
LocaleNonInteractiveInstallTest Tests installing in a different language with a non-dev version string.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.