Same filename and directory in other branches
- 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
- 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
Namespace
Drupal\Tests\config_translation\Functional
File
core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\config_translation\Functional;
use Drupal\FunctionalTests\Installer\InstallerTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
class ConfigTranslationInstallTest extends InstallerTestBase {
use ContentTypeCreationTrait;
protected $langcode = 'eo';
protected $defaultTheme = 'stark';
protected function setUpLanguage() {
mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.eo.po', $this
->getPo('eo'));
parent::setUpLanguage();
$this->translations['Save and continue'] = 'Save and continue eo';
}
protected function getPo($langcode) {
return <<<PO
msgid ""
msgstr ""
msgid "Save and continue"
msgstr "Save and continue {<span class="php-variable">$langcode</span>}"
msgid "Anonymous"
msgstr "Anonymous {<span class="php-variable">$langcode</span>}"
msgid "Language"
msgstr "Language {<span class="php-variable">$langcode</span>}"
PO;
}
public function testConfigTranslation() {
\Drupal::service('module_installer')
->install([
'node',
'field_ui',
]);
$this
->createContentType([
'type' => 'article',
]);
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm([
'predefined_langcode' => 'en',
], 'Add custom language');
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm([
'predefined_langcode' => 'fr',
], 'Add custom language');
$edit = [
'modules[config_translation][enable]' => TRUE,
];
$this
->drupalGet('admin/modules');
$this
->submitForm($edit, 'Install');
$this
->drupalGet('/admin/structure/types/manage/article/fields');
$this
->assertSession()
->statusCodeEquals(200);
}
}
Classes