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