comparison core/modules/system/src/Tests/Installer/DistributionProfileTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 requested theme is used.
50 $this->assertRaw($this->info['distribution']['install']['theme']);
51 // Verify that the "Choose profile" step does not appear.
52 $this->assertNoText('profile');
53
54 parent::setUpLanguage();
55 }
56
57 /**
58 * {@inheritdoc}
59 */
60 protected function setUpProfile() {
61 // This step is skipped, because there is a distribution profile.
62 }
63
64 /**
65 * Confirms that the installation succeeded.
66 */
67 public function testInstalled() {
68 $this->assertUrl('user/1');
69 $this->assertResponse(200);
70 // Confirm that we are logged-in after installation.
71 $this->assertText($this->rootUser->getUsername());
72
73 // Confirm that Drupal recognizes this distribution as the current profile.
74 $this->assertEqual(\Drupal::installProfile(), 'mydistro');
75 $this->assertEqual(Settings::get('install_profile'), 'mydistro', 'The install profile has been written to settings.php.');
76 $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');
77 }
78
79 }