Chris@16
|
1 <?php
|
Chris@16
|
2
|
Chris@16
|
3 namespace Drupal\FunctionalTests\Installer;
|
Chris@16
|
4
|
Chris@16
|
5 use Drupal\Component\Serialization\Yaml;
|
Chris@16
|
6
|
Chris@16
|
7 /**
|
Chris@16
|
8 * Tests multiple distribution profile support.
|
Chris@16
|
9 *
|
Chris@16
|
10 * @group Installer
|
Chris@16
|
11 */
|
Chris@16
|
12 class MultipleDistributionsProfileTest extends InstallerTestBase {
|
Chris@16
|
13
|
Chris@16
|
14 /**
|
Chris@16
|
15 * The distribution profile info.
|
Chris@16
|
16 *
|
Chris@16
|
17 * @var array
|
Chris@16
|
18 */
|
Chris@16
|
19 protected $info;
|
Chris@16
|
20
|
Chris@16
|
21 /**
|
Chris@16
|
22 * {@inheritdoc}
|
Chris@16
|
23 */
|
Chris@16
|
24 protected function prepareEnvironment() {
|
Chris@16
|
25 parent::prepareEnvironment();
|
Chris@16
|
26 // Create two distributions.
|
Chris@16
|
27 foreach (['distribution_one', 'distribution_two'] as $name) {
|
Chris@16
|
28 $info = [
|
Chris@16
|
29 'type' => 'profile',
|
Chris@16
|
30 'core' => \Drupal::CORE_COMPATIBILITY,
|
Chris@16
|
31 'name' => $name . ' profile',
|
Chris@16
|
32 'distribution' => [
|
Chris@16
|
33 'name' => $name,
|
Chris@16
|
34 'install' => [
|
Chris@16
|
35 'theme' => 'bartik',
|
Chris@16
|
36 ],
|
Chris@16
|
37 ],
|
Chris@16
|
38 ];
|
Chris@16
|
39 // File API functions are not available yet.
|
Chris@16
|
40 $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/' . $name;
|
Chris@16
|
41 mkdir($path, 0777, TRUE);
|
Chris@16
|
42 file_put_contents("$path/$name.info.yml", Yaml::encode($info));
|
Chris@16
|
43 }
|
Chris@16
|
44 // Install the first distribution.
|
Chris@16
|
45 $this->profile = 'distribution_one';
|
Chris@16
|
46 }
|
Chris@16
|
47
|
Chris@16
|
48 /**
|
Chris@16
|
49 * {@inheritdoc}
|
Chris@16
|
50 */
|
Chris@16
|
51 protected function setUpLanguage() {
|
Chris@16
|
52 // Verify that the distribution name appears.
|
Chris@16
|
53 $this->assertRaw('distribution_one');
|
Chris@16
|
54 // Verify that the requested theme is used.
|
Chris@16
|
55 $this->assertRaw('bartik');
|
Chris@16
|
56 // Verify that the "Choose profile" step does not appear.
|
Chris@16
|
57 $this->assertNoText('profile');
|
Chris@16
|
58
|
Chris@16
|
59 parent::setUpLanguage();
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 /**
|
Chris@16
|
63 * {@inheritdoc}
|
Chris@16
|
64 */
|
Chris@16
|
65 protected function setUpProfile() {
|
Chris@16
|
66 // This step is skipped, because there is a distribution profile.
|
Chris@16
|
67 }
|
Chris@16
|
68
|
Chris@16
|
69 /**
|
Chris@16
|
70 * Confirms that the installation succeeded.
|
Chris@16
|
71 */
|
Chris@16
|
72 public function testInstalled() {
|
Chris@16
|
73 $this->assertUrl('user/1');
|
Chris@16
|
74 $this->assertResponse(200);
|
Chris@16
|
75 // Confirm that we are logged-in after installation.
|
Chris@18
|
76 $this->assertText($this->rootUser->getAccountName());
|
Chris@16
|
77
|
Chris@16
|
78 // Confirm that Drupal recognizes this distribution as the current profile.
|
Chris@16
|
79 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
|
Chris@16
|
80 $this->assertEqual($this->config('core.extension')->get('profile'), 'distribution_one', 'The install profile has been written to core.extension configuration.');
|
Chris@16
|
81
|
Chris@16
|
82 $this->rebuildContainer();
|
Chris@16
|
83 $this->pass('Container can be rebuilt as distribution is written to configuration.');
|
Chris@16
|
84 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
|
Chris@16
|
85 }
|
Chris@16
|
86
|
Chris@16
|
87 }
|