-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6edc58b
commit 39c5534
Showing
2 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Acquia\Drupal\RecommendedSettings\Tests; | ||
|
||
use Acquia\Drupal\RecommendedSettings\Helpers\Filesystem as DrsFilesystem; | ||
use Acquia\Drupal\RecommendedSettings\Settings; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
class SettingsTest extends TestCase { | ||
|
||
/** | ||
* The recommended settings object. | ||
* | ||
* @var string | ||
*/ | ||
protected $settings; | ||
|
||
/** | ||
* The path to drupal webroot directory. | ||
* | ||
* @var string | ||
*/ | ||
protected $drupalRoot; | ||
|
||
/** | ||
* The symfony file-system object. | ||
* | ||
* @var \Symfony\Component\Filesystem\Filesystem | ||
*/ | ||
protected Filesystem $fileSystem; | ||
|
||
/** | ||
* The symfony file-system object. | ||
* | ||
* @var \Acquia\Drupal\RecommendedSettings\Helpers\Filesystem | ||
*/ | ||
protected DrsFilesystem $drsFileSystem; | ||
|
||
/** | ||
* Set up test environmemt. | ||
*/ | ||
public function setUp(): void { | ||
$this->drupalRoot = dirname(__FILE__); | ||
$docroot = $this->drupalRoot . '/docroot'; | ||
$this->drsFileSystem = new DrsFilesystem(); | ||
$this->drsFileSystem->ensureDirectoryExists($docroot . '/sites/default'); | ||
$this->fileSystem = new Filesystem(); | ||
$this->fileSystem->touch($docroot . '/sites/default/default.settings.php'); | ||
$this->settings = new Settings($docroot, "default"); | ||
$this->settings->generate(); | ||
} | ||
|
||
/** | ||
* Test that the file is created. | ||
*/ | ||
public function testFileIsCreated() { | ||
// Assert that settings/default.global.settings.php file exist. | ||
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/settings/default.global.settings.php')); | ||
// Assert that settings.php file exist. | ||
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings.php')); | ||
// Assert that settings.php file has content. | ||
$content = ' | ||
require DRUPAL_ROOT . "/../vendor/acquia/drupal-recommended-settings/settings/acquia-recommended.settings.php"; | ||
/** | ||
* IMPORTANT. | ||
* | ||
* Do not include additional settings here. Instead, add them to settings | ||
* included by `acquia-recommended.settings.php`. See Acquia\'s documentation for more detail. | ||
* | ||
* @link https://docs.acquia.com/ | ||
*/ | ||
'; | ||
$this->assertEquals($content, file_get_contents($this->drupalRoot . '/docroot/sites/default/settings.php')); | ||
// Assert that default.includes.settings.php file exist. | ||
$this->assertTrue($this->fileSystem->exists($this->drupalRoot . '/docroot/sites/default/settings/default.includes.settings.php')); | ||
// Assert that default.local.settings.php file exist. | ||
$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')); | ||
} | ||
|
||
public function tearDown(): void { | ||
$this->fileSystem->remove($this->drupalRoot . '/docroot'); | ||
$this->fileSystem->remove($this->drupalRoot . '/config'); | ||
} | ||
|
||
} |