Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / FunctionalTests / Installer / InstallerConfigDirectorySetNoDirectoryErrorTest.php
1 <?php
2
3 namespace Drupal\FunctionalTests\Installer;
4
5 use Drupal\Component\Utility\Crypt;
6
7 /**
8  * Tests the installer when a config_directory set up but does not exist.
9  *
10  * @group Installer
11  */
12 class InstallerConfigDirectorySetNoDirectoryErrorTest extends InstallerTestBase {
13
14   /**
15    * The directory where the sync directory should be created during install.
16    *
17    * @var string
18    */
19   protected $configDirectory;
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function prepareEnvironment() {
25     parent::prepareEnvironment();
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   }
36
37   /**
38    * Installer step: Configure settings.
39    */
40   protected function setUpSettings() {
41     // This step should not appear as we had a failure prior to the settings
42     // screen.
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   protected function setUpSite() {
49     // This step should not appear as we had a failure prior to the settings
50     // screen.
51   }
52
53   /**
54    * Verifies that installation failed.
55    */
56   public function testError() {
57     $this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
58     $this->assertFalse(file_exists($this->configDirectory . '/sync') && is_dir($this->configDirectory . '/sync'), "The directory {$this->configDirectory}/sync does not exist.");
59   }
60
61 }