comparison core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.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\Site\Settings;
6 use Drupal\simpletest\InstallerTestBase;
7 use Drupal\Core\Database\Database;
8 use Drupal\Core\DrupalKernel;
9 use Symfony\Component\HttpFoundation\Request;
10
11 /**
12 * Tests the installer with an existing settings file.
13 *
14 * @group Installer
15 */
16 class InstallerExistingSettingsTest extends InstallerTestBase {
17
18 /**
19 * {@inheritdoc}
20 *
21 * Fully configures a preexisting settings.php file before invoking the
22 * 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 // During interactive install we'll change this to a different profile and
33 // this test will ensure that the new value is written to settings.php.
34 $this->settings['settings']['install_profile'] = (object) [
35 'value' => 'minimal',
36 'required' => TRUE,
37 ];
38
39 // Pre-configure database credentials.
40 $connection_info = Database::getConnectionInfo();
41 unset($connection_info['default']['pdo']);
42 unset($connection_info['default']['init_commands']);
43
44 $this->settings['databases']['default'] = (object) [
45 'value' => $connection_info,
46 'required' => TRUE,
47 ];
48
49 // Use the kernel to find the site path because the site.path service should
50 // not be available at this point in the install process.
51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
52 // Pre-configure config directories.
53 $this->settings['config_directories'] = [
54 CONFIG_SYNC_DIRECTORY => (object) [
55 'value' => $site_path . '/files/config_sync',
56 'required' => TRUE,
57 ],
58 ];
59 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
60
61 parent::setUp();
62 }
63
64 /**
65 * {@inheritdoc}
66 */
67 protected function setUpSettings() {
68 // This step should not appear, since settings.php is fully configured
69 // already.
70 }
71
72 /**
73 * Verifies that installation succeeded.
74 */
75 public function testInstaller() {
76 $this->assertUrl('user/1');
77 $this->assertResponse(200);
78 $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.');
79 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');
80 }
81
82 }