HelpTopicTranslatedTestBase.php in Drupal 8
File
core/modules/help_topics/tests/src/Functional/HelpTopicTranslatedTestBase.php
View source
<?php
namespace Drupal\Tests\help_topics\Functional;
use Drupal\Tests\BrowserTestBase;
abstract class HelpTopicTranslatedTestBase extends BrowserTestBase {
protected static $modules = [
'help_topics_test',
'help',
'help_topics',
'block',
];
protected function setUp() {
parent::setUp();
\Drupal::service('theme_installer')
->install([
'seven',
]);
\Drupal::configFactory()
->getEditable('system.theme')
->set('admin', 'seven')
->save(TRUE);
$settings = [
'theme' => 'seven',
'region' => 'help',
];
$this
->placeBlock('help_block', $settings);
$this
->placeBlock('local_tasks_block', $settings);
$this
->placeBlock('local_actions_block', $settings);
$this
->placeBlock('page_title_block', $settings);
$this
->drupalLogin($this
->createUser([
'access administration pages',
'view the administration theme',
'administer permissions',
]));
}
protected function installParameters() {
$parameters = parent::installParameters();
$parameters['parameters']['langcode'] = 'de';
\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;
}
}