InstallerExistingConfigSyncDirectoryProfileHookInstall.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. /**
  4. * Verifies that profiles with hook_install() can't be installed from config.
  5. *
  6. * @group Installer
  7. */
  8. class InstallerExistingConfigSyncDirectoryProfileHookInstall extends InstallerExistingConfigTestBase {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. protected $profile = 'testing_config_install_multilingual';
  13. /**
  14. * {@inheritdoc}
  15. */
  16. protected $existingSyncDirectory = TRUE;
  17. /**
  18. * {@inheritdoc}
  19. */
  20. protected function visitInstaller() {
  21. // Create an .install file with a hook_install() implementation.
  22. $path = $this->siteDirectory . '/profiles/' . $this->profile;
  23. $contents = <<<EOF
  24. <?php
  25. function testing_config_install_multilingual_install() {
  26. }
  27. EOF;
  28. file_put_contents("$path/{$this->profile}.install", $contents);
  29. parent::visitInstaller();
  30. }
  31. /**
  32. * Installer step: Select installation profile.
  33. */
  34. protected function setUpProfile() {
  35. // This is the form we are testing so wait until the test method to do
  36. // assertions.
  37. return;
  38. }
  39. /**
  40. * Installer step: Requirements problem.
  41. */
  42. protected function setUpRequirementsProblem() {
  43. // This form will never be reached.
  44. return;
  45. }
  46. /**
  47. * Installer step: Configure settings.
  48. */
  49. protected function setUpSettings() {
  50. // This form will never be reached.
  51. return;
  52. }
  53. /**
  54. * Final installer step: Configure site.
  55. */
  56. protected function setUpSite() {
  57. // This form will never be reached.
  58. return;
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. protected function getConfigTarball() {
  64. return __DIR__ . '/../../../fixtures/config_install/multilingual.tar.gz';
  65. }
  66. /**
  67. * Tests installing from config is not available due to hook_INSTALL().
  68. */
  69. public function testConfigSync() {
  70. $this->assertSession()->titleEquals('Select an installation profile | Drupal');
  71. $this->assertSession()->responseNotContains('Use existing configuration');
  72. // Remove the install hook and the option to install from existing
  73. // configuration will be available.
  74. unlink("{$this->siteDirectory}/profiles/{$this->profile}/{$this->profile}.install");
  75. $this->getSession()->reload();
  76. $this->assertSession()->titleEquals('Select an installation profile | Drupal');
  77. $this->assertSession()->responseContains('Use existing configuration');
  78. }
  79. }