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