Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Tests\Installer; | |
4 | |
5 use Drupal\Core\DrupalKernel; | |
6 use Drupal\Core\Site\Settings; | |
7 use Drupal\simpletest\InstallerTestBase; | |
8 use Drupal\Core\Database\Database; | |
9 use Symfony\Component\HttpFoundation\Request; | |
10 | |
11 /** | |
12 * Tests the installer with an existing settings file but no install profile. | |
13 * | |
14 * @group Installer | |
15 */ | |
16 class InstallerExistingSettingsMismatchProfileTest extends InstallerTestBase { | |
17 | |
18 /** | |
19 * {@inheritdoc} | |
20 * | |
21 * Configures a preexisting settings.php file without an install_profile | |
22 * setting before invoking the interactive installer. | |
23 */ | |
24 protected function setUp() { | |
25 // Pre-configure hash salt. | |
26 // Any string is valid, so simply use the class name of this test. | |
27 $this->settings['settings']['hash_salt'] = (object) [ | |
28 'value' => __CLASS__, | |
29 'required' => TRUE, | |
30 ]; | |
31 | |
32 // Pre-configure database credentials. | |
33 $connection_info = Database::getConnectionInfo(); | |
34 unset($connection_info['default']['pdo']); | |
35 unset($connection_info['default']['init_commands']); | |
36 | |
37 $this->settings['databases']['default'] = (object) [ | |
38 'value' => $connection_info, | |
39 'required' => TRUE, | |
40 ]; | |
41 | |
42 // During interactive install we'll change this to a different profile and | |
43 // this test will ensure that the new value is written to settings.php. | |
44 $this->settings['settings']['install_profile'] = (object) [ | |
45 'value' => 'minimal', | |
46 'required' => TRUE, | |
47 ]; | |
48 | |
49 // Pre-configure config directories. | |
50 $this->settings['config_directories'] = [ | |
51 CONFIG_SYNC_DIRECTORY => (object) [ | |
52 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync', | |
53 'required' => TRUE, | |
54 ], | |
55 ]; | |
56 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE); | |
57 | |
58 parent::setUp(); | |
59 } | |
60 | |
61 /** | |
62 * {@inheritdoc} | |
63 */ | |
64 protected function visitInstaller() { | |
65 // Provide profile and language in query string to skip these pages. | |
66 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing'); | |
67 } | |
68 | |
69 /** | |
70 * {@inheritdoc} | |
71 */ | |
72 protected function setUpLanguage() { | |
73 // This step is skipped, because there is a lagcode as a query param. | |
74 } | |
75 | |
76 /** | |
77 * {@inheritdoc} | |
78 */ | |
79 protected function setUpProfile() { | |
80 // This step is skipped, because there is a profile as a query param. | |
81 } | |
82 | |
83 /** | |
84 * {@inheritdoc} | |
85 */ | |
86 protected function setUpSettings() { | |
87 // This step should not appear, since settings.php is fully configured | |
88 // already. | |
89 } | |
90 | |
91 /** | |
92 * Verifies that installation succeeded. | |
93 */ | |
94 public function testInstaller() { | |
95 $this->assertUrl('user/1'); | |
96 $this->assertResponse(200); | |
97 $this->assertEqual('testing', \Drupal::installProfile()); | |
98 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php'); | |
99 } | |
100 | |
101 } |