InstallerConfigDirectorySetNoDirectoryErrorTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Component\Utility\Crypt;
  4. /**
  5. * Tests the installer when a config_directory set up but does not exist.
  6. *
  7. * @group Installer
  8. */
  9. class InstallerConfigDirectorySetNoDirectoryErrorTest extends InstallerTestBase {
  10. /**
  11. * The directory where the sync directory should be created during install.
  12. *
  13. * @var string
  14. */
  15. protected $configDirectory;
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected function prepareEnvironment() {
  20. parent::prepareEnvironment();
  21. $this->configDirectory = $this->publicFilesDirectory . '/config_' . Crypt::randomBytesBase64();
  22. $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
  23. 'value' => $this->configDirectory . '/sync',
  24. 'required' => TRUE,
  25. ];
  26. // Create the files directory early so we can test the error case.
  27. mkdir($this->publicFilesDirectory);
  28. // Create a file so the directory can not be created.
  29. file_put_contents($this->configDirectory, 'Test');
  30. }
  31. /**
  32. * Installer step: Configure settings.
  33. */
  34. protected function setUpSettings() {
  35. // This step should not appear as we had a failure prior to the settings
  36. // screen.
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. protected function setUpSite() {
  42. // This step should not appear as we had a failure prior to the settings
  43. // screen.
  44. }
  45. /**
  46. * Verifies that installation failed.
  47. */
  48. public function testError() {
  49. $this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
  50. $this->assertFalse(file_exists($this->configDirectory . '/sync') && is_dir($this->configDirectory . '/sync'), "The directory {$this->configDirectory}/sync does not exist.");
  51. }
  52. }