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