InstallerExistingConfigSyncDirectoryProfileHookInstall.php 2.4 KB

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