Skip to content

Commit 23556d7

Browse files
rajeshreeputravishalkhode1
authored andcommittedNov 21, 2023
ACMS-3281: Update Readme and review feedback updates.
1 parent 7653984 commit 23556d7

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed
 

‎README.md

+40-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ The Acquia Drupal Recommended Settings plugin adds the recommended settings to
33
the Drupal project, so developers won't have to edit settings.php manually.
44

55
The recommended settings includes:
6-
- the required database credentials.
7-
- configuration sync directory path.
8-
- public/private etc. file directory path.
6+
- The required database credentials.
7+
- Configuration sync directory path.
8+
- File directory path i.e public/private etc.
99
- Acquia site studio sync directory path.
1010

1111
It allows your websites to be easily installed in both Acquia Cloud IDE & local
@@ -52,6 +52,43 @@ composer require acquia/drupal-recommended-settings
5252
+ use Acquia\Drupal\RecommendedSettings\Helpers\EnvironmentDetector;
5353
```
5454

55+
## Steps to use Acquia Drupal Recommended Settings with BLT.
56+
- Create an Settings object & call generate method.
57+
```
58+
<?php
59+
60+
/**
61+
* @file
62+
* Include DRS settings.
63+
*/
64+
65+
use Acquia\Drupal\RecommendedSettings\Settings;
66+
67+
// Create settings object.
68+
$settings = new Settings(DRUPAL_ROOT, 'site-uri');
69+
70+
// Database details.
71+
$dbSpec = [
72+
'drupal' => [
73+
'db' => [
74+
// Database name.
75+
'database' => 'drupal',
76+
// Mysql database login username.
77+
'username' => 'drupal',
78+
// Mysql database login password.
79+
'password' => 'drupal',
80+
// Mysql host.
81+
'host' => 'localhost',
82+
// Mysql port.
83+
'port' => '3306',
84+
],
85+
],
86+
];
87+
88+
// Call generate method with database details.
89+
$settings->generate($dbSpec);
90+
```
91+
5592
# License
5693

5794
Copyright (C) 2023 Acquia, Inc.
@@ -64,4 +101,3 @@ This program is distributed in the hope that it will be useful,
64101
but WITHOUT ANY WARRANTY; without even the implied warranty of
65102
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
66103
See the GNU General Public License for more details.
67-

‎config/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ drupal:
55
username: drupal
66
password: drupal
77
host: localhost
8-
port: 3306
8+
port: 3306

‎tests/unit/SettingsTest.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ public function setUp(): void {
4848
$this->fileSystem = new Filesystem();
4949
$this->fileSystem->touch($docroot . '/sites/default/default.settings.php');
5050
$this->settings = new Settings($docroot, "default");
51-
$this->settings->generate();
51+
$this->settings->generate([
52+
'drupal' => [
53+
'db' => [
54+
'database' => 'drs',
55+
'username' => 'drupal',
56+
'password' => 'drupal',
57+
'host' => 'localhost',
58+
'port' => '3306',
59+
],
60+
],
61+
]);
5262
}
5363

5464
/**
@@ -78,6 +88,14 @@ public function testFileIsCreated() {
7888
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings/default.local.settings.php'));
7989
// Assert that local.settings.php file exist.
8090
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings/local.settings.php'));
91+
// Get the local.settings.php file content.
92+
$localSettings = file_get_contents($this->drupalRoot . '/docroot/sites/default/settings/local.settings.php');
93+
// Verify database credentials.
94+
$this->assertStringContainsString("db_name = 'drs'", $localSettings, "The local.settings.php doesn't contains the 'drs' database.");
95+
$this->assertStringContainsString("'username' => 'drupal'", $localSettings, "The local.settings.php doesn't contains the 'drupal' username.");
96+
$this->assertStringContainsString("'password' => 'drupal'", $localSettings, "The local.settings.php doesn't contains the 'drupal' password.");
97+
$this->assertStringContainsString("'host' => 'localhost'", $localSettings, "The local.settings.php doesn't contains the 'localhost' host.");
98+
$this->assertStringContainsString("'port' => '3306'", $localSettings, "The local.settings.php doesn't contains the '3306' port.");
8199
}
82100

83101
public function tearDown(): void {

0 commit comments

Comments
 (0)
Please sign in to comment.