DistributionProfileTranslationQueryTest.php in Drupal 8
File
core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
View source
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\Serialization\Yaml;
class DistributionProfileTranslationQueryTest extends InstallerTestBase {
protected $defaultTheme = 'stark';
protected $langcode = 'de';
protected $info;
protected function prepareEnvironment() {
parent::prepareEnvironment();
$this->info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => 'Distribution profile',
'distribution' => [
'name' => 'My Distribution',
'langcode' => $this->langcode,
'install' => [
'theme' => 'bartik',
],
],
];
$path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/mydistro';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/mydistro.info.yml", Yaml::encode($this->info));
mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this
->getPo('de'));
file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.fr.po', $this
->getPo('fr'));
}
protected function visitInstaller() {
$this
->drupalGet($GLOBALS['base_url'] . '/core/install.php' . '?langcode=fr');
}
protected function setUpLanguage() {
}
protected function setUpProfile() {
}
protected function setUpSettings() {
$elements = $this
->xpath('//input[@type="submit"]/@value');
$this
->assertEqual(current($elements)
->getText(), 'Save and continue de');
$this->translations['Save and continue'] = 'Save and continue de';
$direction = $this
->getSession()
->getPage()
->find('xpath', '/@dir')
->getText();
$this
->assertEqual($direction, 'ltr');
$this
->assertRaw($this->info['distribution']['name']);
$this
->assertRaw($this->info['distribution']['install']['theme']);
$this
->assertNoText('profile');
parent::setUpSettings();
}
public function testInstalled() {
$this
->assertUrl('user/1');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertText($this->rootUser
->getDisplayName());
$this
->drupalGet('admin/config/regional/language');
$this
->assertText('German');
$this
->assertNoText('English');
}
protected function getPo($langcode) {
return <<<ENDPO
msgid ""
msgstr ""
msgid "Save and continue"
msgstr "Save and continue {<span class="php-variable">$langcode</span>}"
ENDPO;
}
}