3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\Serialization\Yaml;
8 * Tests distribution profile support with a 'langcode' query string.
12 * @see \Drupal\FunctionalTests\Installer\DistributionProfileTranslationTest
14 class DistributionProfileTranslationQueryTest extends InstallerTestBase {
19 protected $langcode = 'de';
22 * The distribution profile info.
31 protected function prepareEnvironment() {
32 parent::prepareEnvironment();
35 'core' => \Drupal::CORE_COMPATIBILITY,
36 'name' => 'Distribution profile',
38 'name' => 'My Distribution',
39 'langcode' => $this->langcode,
45 // File API functions are not available yet.
46 $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/mydistro';
47 mkdir($path, 0777, TRUE);
48 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info));
49 // Place a custom local translation in the translations directory.
50 mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
51 file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
52 file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.fr.po', $this->getPo('fr'));
58 protected function visitInstaller() {
59 // Pass a different language code than the one set in the distribution
60 // profile. This distribution language should still be used.
61 // The unrouted URL assembler does not exist at this point, so we build the
63 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php' . '?langcode=fr');
69 protected function setUpLanguage() {
70 // This step is skipped, because the distribution profile uses a fixed
77 protected function setUpProfile() {
78 // This step is skipped, because there is a distribution profile.
84 protected function setUpSettings() {
85 // The language should have been automatically detected, all following
86 // screens should be translated already.
87 $elements = $this->xpath('//input[@type="submit"]/@value');
88 $this->assertEqual(current($elements)->getText(), 'Save and continue de');
89 $this->translations['Save and continue'] = 'Save and continue de';
91 // Check the language direction.
92 $direction = $this->getSession()->getPage()->find('xpath', '/@dir')->getText();
93 $this->assertEqual($direction, 'ltr');
95 // Verify that the distribution name appears.
96 $this->assertRaw($this->info['distribution']['name']);
97 // Verify that the requested theme is used.
98 $this->assertRaw($this->info['distribution']['install']['theme']);
99 // Verify that the "Choose profile" step does not appear.
100 $this->assertNoText('profile');
102 parent::setUpSettings();
106 * Confirms that the installation succeeded.
108 public function testInstalled() {
109 $this->assertUrl('user/1');
110 $this->assertResponse(200);
112 // Confirm that we are logged-in after installation.
113 $this->assertText($this->rootUser->getDisplayName());
115 // Verify German was configured but not English.
116 $this->drupalGet('admin/config/regional/language');
117 $this->assertText('German');
118 $this->assertNoText('English');
122 * Returns the string for the test .po file.
124 * @param string $langcode
127 * Contents for the test .po file.
129 protected function getPo($langcode) {
134 msgid "Save and continue"
135 msgstr "Save and continue $langcode"