More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / modules / system / src / Tests / Installer / InstallerConfigDirectorySetNoDirectoryErrorTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Installer;
4
5 use Drupal\Component\Utility\Crypt;
6 use Drupal\simpletest\InstallerTestBase;
7
8 /**
9  * Tests the installer when a config_directory set up but does not exist.
10  *
11  * @group Installer
12  */
13 class InstallerConfigDirectorySetNoDirectoryErrorTest extends InstallerTestBase {
14
15   /**
16    * The directory where the sync directory should be created during install.
17    *
18    * @var string
19    */
20   protected $configDirectory;
21
22   /**
23    * {@inheritdoc}
24    */
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',
29       'required' => TRUE,
30     ];
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');
35     parent::setUp();
36   }
37
38   /**
39    * Installer step: Configure settings.
40    */
41   protected function setUpSettings() {
42     // This step should not appear as we had a failure prior to the settings
43     // screen.
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   protected function setUpSite() {
50     // This step should not appear as we had a failure prior to the settings
51     // screen.
52   }
53
54   /**
55    * Verifies that installation failed.
56    */
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.");
60   }
61
62 }