Chris@16
|
1 <?php
|
Chris@16
|
2
|
Chris@16
|
3 namespace Drupal\FunctionalTests\Installer;
|
Chris@16
|
4
|
Chris@16
|
5 use Drupal\Core\Serialization\Yaml;
|
Chris@16
|
6
|
Chris@16
|
7 /**
|
Chris@16
|
8 * Tests distribution profile support.
|
Chris@16
|
9 *
|
Chris@16
|
10 * @group Installer
|
Chris@16
|
11 *
|
Chris@16
|
12 * @see \Drupal\FunctionalTests\Installer\DistributionProfileTest
|
Chris@16
|
13 */
|
Chris@16
|
14 class DistributionProfileTranslationTest extends InstallerTestBase {
|
Chris@16
|
15
|
Chris@16
|
16 /**
|
Chris@16
|
17 * {@inheritdoc}
|
Chris@16
|
18 */
|
Chris@16
|
19 protected $langcode = 'de';
|
Chris@16
|
20
|
Chris@16
|
21 /**
|
Chris@16
|
22 * The distribution profile info.
|
Chris@16
|
23 *
|
Chris@16
|
24 * @var array
|
Chris@16
|
25 */
|
Chris@16
|
26 protected $info;
|
Chris@16
|
27
|
Chris@16
|
28 /**
|
Chris@16
|
29 * {@inheritdoc}
|
Chris@16
|
30 */
|
Chris@16
|
31 protected function prepareEnvironment() {
|
Chris@16
|
32 parent::prepareEnvironment();
|
Chris@16
|
33 $this->info = [
|
Chris@16
|
34 'type' => 'profile',
|
Chris@16
|
35 'core' => \Drupal::CORE_COMPATIBILITY,
|
Chris@16
|
36 'name' => 'Distribution profile',
|
Chris@16
|
37 'distribution' => [
|
Chris@16
|
38 'name' => 'My Distribution',
|
Chris@16
|
39 'langcode' => $this->langcode,
|
Chris@16
|
40 'install' => [
|
Chris@16
|
41 'theme' => 'bartik',
|
Chris@16
|
42 ],
|
Chris@16
|
43 ],
|
Chris@16
|
44 ];
|
Chris@16
|
45 // File API functions are not available yet.
|
Chris@16
|
46 $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/mydistro';
|
Chris@16
|
47 mkdir($path, 0777, TRUE);
|
Chris@16
|
48 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info));
|
Chris@16
|
49
|
Chris@16
|
50 // Place a custom local translation in the translations directory.
|
Chris@16
|
51 mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
|
Chris@16
|
52 file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
|
Chris@16
|
53 }
|
Chris@16
|
54
|
Chris@16
|
55 /**
|
Chris@16
|
56 * {@inheritdoc}
|
Chris@16
|
57 */
|
Chris@16
|
58 protected function setUpLanguage() {
|
Chris@16
|
59 // This step is skipped, because the distribution profile uses a fixed
|
Chris@16
|
60 // language.
|
Chris@16
|
61 }
|
Chris@16
|
62
|
Chris@16
|
63 /**
|
Chris@16
|
64 * {@inheritdoc}
|
Chris@16
|
65 */
|
Chris@16
|
66 protected function setUpProfile() {
|
Chris@16
|
67 // This step is skipped, because there is a distribution profile.
|
Chris@16
|
68 }
|
Chris@16
|
69
|
Chris@16
|
70 /**
|
Chris@16
|
71 * {@inheritdoc}
|
Chris@16
|
72 */
|
Chris@16
|
73 protected function setUpSettings() {
|
Chris@16
|
74 // The language should have been automatically detected, all following
|
Chris@16
|
75 // screens should be translated already.
|
Chris@16
|
76 $elements = $this->xpath('//input[@type="submit"]/@value');
|
Chris@16
|
77 $this->assertEqual(current($elements)->getText(), 'Save and continue de');
|
Chris@16
|
78 $this->translations['Save and continue'] = 'Save and continue de';
|
Chris@16
|
79
|
Chris@16
|
80 // Check the language direction.
|
Chris@16
|
81 $direction = current($this->xpath('/@dir'))->getText();
|
Chris@16
|
82 $this->assertEqual($direction, 'ltr');
|
Chris@16
|
83
|
Chris@16
|
84 // Verify that the distribution name appears.
|
Chris@16
|
85 $this->assertRaw($this->info['distribution']['name']);
|
Chris@16
|
86 // Verify that the requested theme is used.
|
Chris@16
|
87 $this->assertRaw($this->info['distribution']['install']['theme']);
|
Chris@16
|
88 // Verify that the "Choose profile" step does not appear.
|
Chris@16
|
89 $this->assertNoText('profile');
|
Chris@16
|
90
|
Chris@16
|
91 parent::setUpSettings();
|
Chris@16
|
92 }
|
Chris@16
|
93
|
Chris@16
|
94 /**
|
Chris@16
|
95 * Confirms that the installation succeeded.
|
Chris@16
|
96 */
|
Chris@16
|
97 public function testInstalled() {
|
Chris@16
|
98 $this->assertUrl('user/1');
|
Chris@16
|
99 $this->assertResponse(200);
|
Chris@16
|
100
|
Chris@16
|
101 // Confirm that we are logged-in after installation.
|
Chris@16
|
102 $this->assertText($this->rootUser->getDisplayName());
|
Chris@16
|
103
|
Chris@16
|
104 // Verify German was configured but not English.
|
Chris@16
|
105 $this->drupalGet('admin/config/regional/language');
|
Chris@16
|
106 $this->assertText('German');
|
Chris@16
|
107 $this->assertNoText('English');
|
Chris@16
|
108 }
|
Chris@16
|
109
|
Chris@16
|
110 /**
|
Chris@16
|
111 * Returns the string for the test .po file.
|
Chris@16
|
112 *
|
Chris@16
|
113 * @param string $langcode
|
Chris@16
|
114 * The language code.
|
Chris@16
|
115 * @return string
|
Chris@16
|
116 * Contents for the test .po file.
|
Chris@16
|
117 */
|
Chris@16
|
118 protected function getPo($langcode) {
|
Chris@16
|
119 return <<<ENDPO
|
Chris@16
|
120 msgid ""
|
Chris@16
|
121 msgstr ""
|
Chris@16
|
122
|
Chris@16
|
123 msgid "Save and continue"
|
Chris@16
|
124 msgstr "Save and continue $langcode"
|
Chris@16
|
125 ENDPO;
|
Chris@16
|
126 }
|
Chris@16
|
127
|
Chris@16
|
128 }
|