You are here

protected function HelpTopicTranslatedTestBase::installParameters in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/help_topics/tests/src/Functional/HelpTopicTranslatedTestBase.php \Drupal\Tests\help_topics\Functional\HelpTopicTranslatedTestBase::installParameters()

Returns the parameters that will be used when Simpletest installs Drupal.

Return value

array Array of parameters for use in install_drupal().

Overrides FunctionalTestSetupTrait::installParameters

See also

install_drupal()

install_state_defaults()

File

core/modules/help_topics/tests/src/Functional/HelpTopicTranslatedTestBase.php, line 58

Class

HelpTopicTranslatedTestBase
Provides a base class for functional help topic tests that use translation.

Namespace

Drupal\Tests\help_topics\Functional

Code

protected function installParameters() {
  $parameters = parent::installParameters();

  // Install in German. This will ensure the language and locale modules are
  // installed.
  $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 = <<<ENDPO
msgid ""
msgstr ""

msgid "ABC Help Test module"
msgstr "ABC-Hilfetestmodul"

msgid "Test translation."
msgstr "Übersetzung testen."

msgid "Nonworditem totranslate."
msgstr "Nonwordgerman sdfwedrsdf."

ENDPO;
  include_once $this->root . '/core/includes/install.core.inc';
  $version = _install_get_version_info(\Drupal::VERSION)['major'] . '.0.0';
  file_put_contents($this->publicFilesDirectory . "/translations/drupal-{$version}.de.po", $contents);
  return $parameters;
}