3d2c4c44ab6fe7d37d3f0b23cec659a842d8787a
[yaffs-website] / web / core / modules / system / src / Tests / Installer / DistributionProfileTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Installer;
4
5 use Drupal\Core\Serialization\Yaml;
6 use Drupal\Core\Site\Settings;
7 use Drupal\simpletest\InstallerTestBase;
8
9 /**
10  * Tests distribution profile support.
11  *
12  * @group Installer
13  */
14 class DistributionProfileTest extends InstallerTestBase {
15
16   /**
17    * The distribution profile info.
18    *
19    * @var array
20    */
21   protected $info;
22
23   protected function setUp() {
24     $this->info = [
25       'type' => 'profile',
26       'core' => \Drupal::CORE_COMPATIBILITY,
27       'name' => 'Distribution profile',
28       'distribution' => [
29         'name' => 'My Distribution',
30         'install' => [
31           'theme' => 'bartik',
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
40     parent::setUp();
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   protected function setUpLanguage() {
47     // Verify that the distribution name appears.
48     $this->assertRaw($this->info['distribution']['name']);
49     // Verify that the distribution name is used in the site title.
50     $this->assertTitle('Choose language | ' . $this->info['distribution']['name']);
51     // Verify that the requested theme is used.
52     $this->assertRaw($this->info['distribution']['install']['theme']);
53     // Verify that the "Choose profile" step does not appear.
54     $this->assertNoText('profile');
55
56     parent::setUpLanguage();
57   }
58
59   /**
60    * {@inheritdoc}
61    */
62   protected function setUpProfile() {
63     // This step is skipped, because there is a distribution profile.
64   }
65
66   /**
67    * Confirms that the installation succeeded.
68    */
69   public function testInstalled() {
70     $this->assertUrl('user/1');
71     $this->assertResponse(200);
72     // Confirm that we are logged-in after installation.
73     $this->assertText($this->rootUser->getUsername());
74
75     // Confirm that Drupal recognizes this distribution as the current profile.
76     $this->assertEqual(\Drupal::installProfile(), 'mydistro');
77     $this->assertEqual(Settings::get('install_profile'), 'mydistro', 'The install profile has been written to settings.php.');
78     $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');
79   }
80
81 }