3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Core\Serialization\Yaml;
6 use Drupal\simpletest\InstallerTestBase;
9 * Tests distribution profile support.
13 * @see \Drupal\system\Tests\Installer\DistributionProfileTest
15 class DistributionProfileTranslationTest 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'));
61 parent::visitInstaller();
67 protected function setUpLanguage() {
68 // This step is skipped, because the distribution profile uses a fixed
75 protected function setUpProfile() {
76 // This step is skipped, because there is a distribution profile.
82 protected function setUpSettings() {
83 // The language should have been automatically detected, all following
84 // screens should be translated already.
85 $elements = $this->xpath('//input[@type="submit"]/@value');
86 $this->assertEqual((string) current($elements), 'Save and continue de');
87 $this->translations['Save and continue'] = 'Save and continue de';
89 // Check the language direction.
90 $direction = (string) current($this->xpath('/html/@dir'));
91 $this->assertEqual($direction, 'ltr');
93 // Verify that the distribution name appears.
94 $this->assertRaw($this->info['distribution']['name']);
95 // Verify that the requested theme is used.
96 $this->assertRaw($this->info['distribution']['install']['theme']);
97 // Verify that the "Choose profile" step does not appear.
98 $this->assertNoText('profile');
100 parent::setUpSettings();
105 * Confirms that the installation succeeded.
107 public function testInstalled() {
108 $this->assertUrl('user/1');
109 $this->assertResponse(200);
111 // Confirm that we are logged-in after installation.
112 $this->assertText($this->rootUser->getDisplayName());
114 // Verify German was configured but not English.
115 $this->drupalGet('admin/config/regional/language');
116 $this->assertText('German');
117 $this->assertNoText('English');
121 * Returns the string for the test .po file.
123 * @param string $langcode
126 * Contents for the test .po file.
128 protected function getPo($langcode) {
133 msgid "Save and continue"
134 msgstr "Save and continue $langcode"