Skip to content

Commit

Permalink
ACMS-3281: Update Readme and review feedback updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshreeputra committed Nov 16, 2023
1 parent 39c5534 commit 38495a5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ The Acquia Drupal Recommended Settings plugin adds the recommended settings to
the Drupal project, so developers won't have to edit settings.php manually.

The recommended settings includes:
- the required database credentials.
- configuration sync directory path.
- public/private etc. file directory path.
- The required database credentials.
- Configuration sync directory path.
- File directory path i.e public/private etc.
- Acquia site studio sync directory path.

It allows your websites to be easily installed in both Acquia Cloud IDE & local
Expand All @@ -30,7 +30,42 @@ composer update acquia/blt -W
- Latest release of BLT will download the acquia/drupal-recommended-settings
plugin automatically as dependency.

- add details for How to call generate() method.
## Steps to use Acquia Drupal Recommended Settings with BLT.
- Create an Settings object & call generate method.
```
<?php
/**
* @file
* Include DRS settings.
*/
use Acquia\Drupal\RecommendedSettings\Settings;
// Create settings object.
$settings = new Settings(DRUPAL_ROOT, 'site-uri');
// Database details.
$dbSpec = [
'drupal' => [
'db' => [
// Database name.
'database' => 'drupal',
// Mysql database login username.
'username' => 'drupal',
// Mysql database login password.
'password' => 'drupal',
// Mysql host.
'host' => 'localhost',
// Mysql port.
'port' => '3306',
],
],
];
// Call generate method with database details.
$settings->generate($dbSpec);
```

# License

Expand Down
2 changes: 1 addition & 1 deletion config/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ drupal:
username: drupal
password: drupal
host: localhost
port: 3306
port: 3306
20 changes: 19 additions & 1 deletion tests/unit/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ public function setUp(): void {
$this->fileSystem = new Filesystem();
$this->fileSystem->touch($docroot . '/sites/default/default.settings.php');
$this->settings = new Settings($docroot, "default");
$this->settings->generate();
$this->settings->generate([
'drupal' => [
'db' => [
'database' => 'drs',
'username' => 'drupal',
'password' => 'drupal',
'host' => 'localhost',
'port' => '3306',
],
],
]);
}

/**
Expand Down Expand Up @@ -78,6 +88,14 @@ public function testFileIsCreated() {
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings/default.local.settings.php'));
// Assert that local.settings.php file exist.
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings/local.settings.php'));
// Get the local.settings.php file content.
$localSettings = file_get_contents($this->drupalRoot . '/docroot/sites/default/settings/local.settings.php');
// Verify database credentials.
$this->assertStringContainsString("db_name = 'drs'", $localSettings, "The local.settings.php doesn't contains the 'drs' database.");
$this->assertStringContainsString("'username' => 'drupal'", $localSettings, "The local.settings.php doesn't contains the 'drupal' username.");
$this->assertStringContainsString("'password' => 'drupal'", $localSettings, "The local.settings.php doesn't contains the 'drupal' password.");
$this->assertStringContainsString("'host' => 'localhost'", $localSettings, "The local.settings.php doesn't contains the 'localhost' host.");
$this->assertStringContainsString("'port' => '3306'", $localSettings, "The local.settings.php doesn't contains the '3306' port.");
}

public function tearDown(): void {
Expand Down

0 comments on commit 38495a5

Please sign in to comment.