View source
<?php
namespace Drupal\system\Tests\Installer;
use Drupal\Core\Database\Database;
use Drupal\simpletest\InstallerTestBase;
use Drupal\user\Entity\User;
class InstallerTranslationTest extends InstallerTestBase {
protected $langcode = 'de';
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.de.po', $this
->getPo('de'));
parent::setUpLanguage();
$elements = $this
->xpath('//input[@type="submit"]/@value');
$this
->assertEqual((string) current($elements), 'Save and continue de');
$this->translations['Save and continue'] = 'Save and continue de';
$direction = (string) current($this
->xpath('/html/@dir'));
$this
->assertEqual($direction, 'ltr');
}
protected function setUpSettings() {
Database::getConnection('default')
->query('CREATE TABLE {drupal_install_test} (id int NULL)');
parent::setUpSettings();
$this
->assertRaw('Beheben Sie alle Probleme unten, um die Installation fortzusetzen. Informationen zur Konfiguration der Datenbankserver finden Sie in der <a href="https://www.drupal.org/getting-started/install">Installationshandbuch</a>, oder kontaktieren Sie Ihren Hosting-Anbieter.');
$this
->assertRaw('<strong>CREATE</strong> ein Test-Tabelle auf Ihrem Datenbankserver mit dem Befehl <em class="placeholder">CREATE TABLE {drupal_install_test} (id int NULL)</em> fehlgeschlagen.');
Database::getConnection('default')
->query('DROP TABLE {drupal_install_test}');
parent::setUpSettings();
}
public function testInstaller() {
$this
->assertUrl('user/1');
$this
->assertResponse(200);
$this
->drupalGet('admin/config/regional/language');
$this
->assertText('German');
$this
->assertNoText('English');
$this
->rebuildContainer();
$account = User::load(0);
$this
->assertEqual($account
->language()
->getId(), 'en', 'Anonymous user is English.');
$account = User::load(1);
$this
->assertEqual($account
->language()
->getId(), 'en', 'Administrator user is English.');
$account = $this
->drupalCreateUser();
$this
->assertEqual($account
->language()
->getId(), 'de', 'New user is German.');
$this
->drupalPostForm('admin/modules', array(
'modules[Web services][basic_auth][enable]' => TRUE,
), t('Install'));
$this
->assertResponse(200);
$edit = array(
'preprocess_css' => FALSE,
);
$this
->drupalPostForm('admin/config/development/performance', $edit, t('Save configuration'));
$this
->drupalGet('<front>');
$this
->assertRaw('classy/css/components/action-links.css');
$test_samples = [
'Save and continue',
'Anonymous',
];
foreach ($test_samples as $sample) {
$edit = array();
$edit['langcode'] = 'de';
$edit['translation'] = 'translated';
$edit['string'] = $sample;
$this
->drupalPostForm('admin/config/regional/translate', $edit, t('Filter'));
$this
->assertText($sample . ' de');
}
$language_manager = \Drupal::languageManager();
$config = \Drupal::config('user.settings');
$override_de = $language_manager
->getLanguageConfigOverride('de', 'user.settings');
$override_en = $language_manager
->getLanguageConfigOverride('en', 'user.settings');
$this
->assertEqual($config
->get('anonymous'), 'Anonymous de');
$this
->assertEqual($config
->get('langcode'), 'de');
$this
->assertTrue($override_de
->isNew());
$this
->assertTrue($override_en
->isNew());
$edit = [
'predefined_langcode' => 'en',
];
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$override_en = $language_manager
->getLanguageConfigOverride('en', 'user.settings');
$this
->assertFalse($override_en
->isNew());
$this
->assertEqual($override_en
->get('anonymous'), 'Anonymous');
}
protected function getPo($langcode) {
return <<<ENDPO
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 "Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider."
msgstr "Beheben Sie alle Probleme unten, um die Installation fortzusetzen. Informationen zur Konfiguration der Datenbankserver finden Sie in der <a href="https://www.drupal.org/getting-started/install">Installationshandbuch</a>, oder kontaktieren Sie Ihren Hosting-Anbieter."
msgid "Failed to <strong>CREATE</strong> a test table on your database server with the command %query. The server reports the following message: %error.<p>Are you sure the configured username has the necessary permissions to create tables in the database?</p>"
msgstr "<strong>CREATE</strong> ein Test-Tabelle auf Ihrem Datenbankserver mit dem Befehl %query fehlgeschlagen."
ENDPO;
}
}