diff --git a/README.md b/README.md index c12f3ea..7e2b9d0 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. + ``` + [ + '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 diff --git a/config/build.yml b/config/build.yml index 680995f..a8ec6cb 100644 --- a/config/build.yml +++ b/config/build.yml @@ -5,4 +5,4 @@ drupal: username: drupal password: drupal host: localhost - port: 3306 \ No newline at end of file + port: 3306 diff --git a/tests/unit/SettingsTest.php b/tests/unit/SettingsTest.php index 20fd40d..72e0b71 100644 --- a/tests/unit/SettingsTest.php +++ b/tests/unit/SettingsTest.php @@ -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', + ], + ], + ]); } /** @@ -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 {