3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\Serialization\Yaml;
8 * Tests distribution profile support.
12 * @see \Drupal\FunctionalTests\Installer\DistributionProfileTest
14 class DistributionProfileTranslationTest 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));
50 // Place a custom local translation in the translations directory.
51 mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
52 file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
58 protected function setUpLanguage() {
59 // This step is skipped, because the distribution profile uses a fixed
66 protected function setUpProfile() {
67 // This step is skipped, because there is a distribution profile.
73 protected function setUpSettings() {
74 // The language should have been automatically detected, all following
75 // screens should be translated already.
76 $elements = $this->xpath('//input[@type="submit"]/@value');
77 $this->assertEqual(current($elements)->getText(), 'Save and continue de');
78 $this->translations['Save and continue'] = 'Save and continue de';
80 // Check the language direction.
81 $direction = current($this->xpath('/@dir'))->getText();
82 $this->assertEqual($direction, 'ltr');
84 // Verify that the distribution name appears.
85 $this->assertRaw($this->info['distribution']['name']);
86 // Verify that the requested theme is used.
87 $this->assertRaw($this->info['distribution']['install']['theme']);
88 // Verify that the "Choose profile" step does not appear.
89 $this->assertNoText('profile');
91 parent::setUpSettings();
95 * Confirms that the installation succeeded.
97 public function testInstalled() {
98 $this->assertUrl('user/1');
99 $this->assertResponse(200);
101 // Confirm that we are logged-in after installation.
102 $this->assertText($this->rootUser->getDisplayName());
104 // Verify German was configured but not English.
105 $this->drupalGet('admin/config/regional/language');
106 $this->assertText('German');
107 $this->assertNoText('English');
111 * Returns the string for the test .po file.
113 * @param string $langcode
116 * Contents for the test .po file.
118 protected function getPo($langcode) {
123 msgid "Save and continue"
124 msgstr "Save and continue $langcode"