InstallerConfigDirectorySetNoDirectoryErrorTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. * {@inheritdoc}
  12. */
  13. protected $defaultTheme = 'stark';
  14. /**
  15. * The directory where the sync directory should be created during install.
  16. *
  17. * @var string
  18. */
  19. protected $configDirectory;
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected function prepareEnvironment() {
  24. parent::prepareEnvironment();
  25. $this->configDirectory = $this->publicFilesDirectory . '/config_' . Crypt::randomBytesBase64();
  26. $this->settings['settings']['config_sync_directory'] = (object) [
  27. 'value' => $this->configDirectory . '/sync',
  28. 'required' => TRUE,
  29. ];
  30. // Create the files directory early so we can test the error case.
  31. mkdir($this->publicFilesDirectory);
  32. // Create a file so the directory can not be created.
  33. file_put_contents($this->configDirectory, 'Test');
  34. }
  35. /**
  36. * Installer step: Configure settings.
  37. */
  38. protected function setUpSettings() {
  39. // This step should not appear as we had a failure prior to the settings
  40. // screen.
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function setUpSite() {
  46. // This step should not appear as we had a failure prior to the settings
  47. // screen.
  48. }
  49. /**
  50. * Verifies that installation failed.
  51. */
  52. public function testError() {
  53. $this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
  54. $this->assertDirectoryNotExists($this->configDirectory . '/sync');
  55. }
  56. }