Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\FunctionalTests\Installer;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Component\Serialization\Yaml;
|
Chris@0
|
6 use Drupal\Core\Site\Settings;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Tests multiple distribution profile support.
|
Chris@0
|
10 *
|
Chris@0
|
11 * @group Installer
|
Chris@0
|
12 */
|
Chris@0
|
13 class MultipleDistributionsProfileTest extends InstallerTestBase {
|
Chris@0
|
14
|
Chris@0
|
15 /**
|
Chris@0
|
16 * The distribution profile info.
|
Chris@0
|
17 *
|
Chris@0
|
18 * @var array
|
Chris@0
|
19 */
|
Chris@0
|
20 protected $info;
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * {@inheritdoc}
|
Chris@0
|
24 */
|
Chris@0
|
25 protected function prepareEnvironment() {
|
Chris@0
|
26 parent::prepareEnvironment();
|
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->root . DIRECTORY_SEPARATOR . $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
|
Chris@0
|
49 /**
|
Chris@0
|
50 * {@inheritdoc}
|
Chris@0
|
51 */
|
Chris@0
|
52 protected function setUpLanguage() {
|
Chris@0
|
53 // Verify that the distribution name appears.
|
Chris@0
|
54 $this->assertRaw('distribution_one');
|
Chris@0
|
55 // Verify that the requested theme is used.
|
Chris@0
|
56 $this->assertRaw('bartik');
|
Chris@0
|
57 // Verify that the "Choose profile" step does not appear.
|
Chris@0
|
58 $this->assertNoText('profile');
|
Chris@0
|
59
|
Chris@0
|
60 parent::setUpLanguage();
|
Chris@0
|
61 }
|
Chris@0
|
62
|
Chris@0
|
63 /**
|
Chris@0
|
64 * {@inheritdoc}
|
Chris@0
|
65 */
|
Chris@0
|
66 protected function setUpProfile() {
|
Chris@0
|
67 // This step is skipped, because there is a distribution profile.
|
Chris@0
|
68 }
|
Chris@0
|
69
|
Chris@0
|
70 /**
|
Chris@0
|
71 * Confirms that the installation succeeded.
|
Chris@0
|
72 */
|
Chris@0
|
73 public function testInstalled() {
|
Chris@0
|
74 $this->assertUrl('user/1');
|
Chris@0
|
75 $this->assertResponse(200);
|
Chris@0
|
76 // Confirm that we are logged-in after installation.
|
Chris@0
|
77 $this->assertText($this->rootUser->getUsername());
|
Chris@0
|
78
|
Chris@0
|
79 // Confirm that Drupal recognizes this distribution as the current profile.
|
Chris@0
|
80 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
|
Chris@0
|
81 $this->assertEqual(Settings::get('install_profile'), 'distribution_one', 'The install profile has been written to settings.php.');
|
Chris@0
|
82 $this->assertEqual($this->config('core.extension')->get('profile'), 'distribution_one', 'The install profile has been written to core.extension configuration.');
|
Chris@0
|
83
|
Chris@0
|
84 $this->rebuildContainer();
|
Chris@0
|
85 $this->pass('Container can be rebuilt as distribution is written to configuration.');
|
Chris@0
|
86 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
|
Chris@0
|
87 }
|
Chris@0
|
88
|
Chris@0
|
89 }
|