3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Core\Serialization\Yaml;
6 use Drupal\simpletest\InstallerTestBase;
9 * Tests distribution profile support with a 'langcode' query string.
13 * @see \Drupal\system\Tests\Installer\DistributionProfileTranslationTest
15 class DistributionProfileTranslationQueryTest extends InstallerTestBase {
20 protected $langcode = 'de';
23 * The distribution profile info.
32 protected function setUp() {
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->siteDirectory . '/profiles/mydistro';
47 mkdir($path, 0777, TRUE);
48 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info));
56 protected function visitInstaller() {
57 // Place a custom local translation in the translations directory.
58 mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
59 file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
60 file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.fr.po', $this->getPo('fr'));
62 // Pass a different language code than the one set in the distribution
63 // profile. This distribution language should still be used.
64 // The unrouted URL assembler does not exist at this point, so we build the
66 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php' . '?langcode=fr');
67 // The language should have been automatically detected, all following
68 // screens should be translated already.
69 $elements = $this->xpath('//input[@type="submit"]/@value');
70 $this->assertEqual((string) current($elements), 'Save and continue de');
71 $this->translations['Save and continue'] = 'Save and continue de';
73 // Check the language direction.
74 $direction = (string) current($this->xpath('/html/@dir'));
75 $this->assertEqual($direction, 'ltr');
77 // Verify that the distribution name appears.
78 $this->assertRaw($this->info['distribution']['name']);
79 // Verify that the requested theme is used.
80 $this->assertRaw($this->info['distribution']['install']['theme']);
81 // Verify that the "Choose profile" step does not appear.
82 $this->assertNoText('profile');
88 protected function setUpLanguage() {
89 // This step is skipped, because the distribution profile uses a fixed
96 protected function setUpProfile() {
97 // This step is skipped, because there is a distribution profile.
101 * Confirms that the installation succeeded.
103 public function testInstalled() {
104 $this->assertUrl('user/1');
105 $this->assertResponse(200);
107 // Confirm that we are logged-in after installation.
108 $this->assertText($this->rootUser->getDisplayName());
110 // Verify German was configured but not English.
111 $this->drupalGet('admin/config/regional/language');
112 $this->assertText('German');
113 $this->assertNoText('English');
117 * Returns the string for the test .po file.
119 * @param string $langcode
122 * Contents for the test .po file.
124 protected function getPo($langcode) {
129 msgid "Save and continue"
130 msgstr "Save and continue $langcode"