3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Component\Utility\Crypt;
6 use Drupal\simpletest\InstallerTestBase;
9 * Tests the installer when a config_directory set up but does not exist.
13 class InstallerConfigDirectorySetNoDirectoryErrorTest extends InstallerTestBase {
16 * The directory where the sync directory should be created during install.
20 protected $configDirectory;
25 protected function setUp() {
26 $this->configDirectory = $this->publicFilesDirectory . '/config_' . Crypt::randomBytesBase64();
27 $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
28 'value' => $this->configDirectory . '/sync',
31 // Create the files directory early so we can test the error case.
32 mkdir($this->publicFilesDirectory);
33 // Create a file so the directory can not be created.
34 file_put_contents($this->configDirectory, 'Test');
39 * Installer step: Configure settings.
41 protected function setUpSettings() {
42 // This step should not appear as we had a failure prior to the settings
49 protected function setUpSite() {
50 // This step should not appear as we had a failure prior to the settings
55 * Verifies that installation failed.
57 public function testError() {
58 $this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
59 $this->assertFalse(file_exists($this->configDirectory . '/sync') && is_dir($this->configDirectory . '/sync'), "The directory {$this->configDirectory}/sync does not exist.");