InstallerExistingConfigProfileHookInstall.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 InstallerExistingConfigProfileHookInstall extends InstallerExistingConfigTestBase {
  9. protected $profile = 'config_profile_with_hook_install';
  10. /**
  11. * {@inheritdoc}
  12. */
  13. protected function visitInstaller() {
  14. // Create an .install file with a hook_install() implementation.
  15. $path = $this->siteDirectory . '/profiles/' . $this->profile;
  16. $contents = <<<EOF
  17. <?php
  18. function config_profile_with_hook_install_install() {
  19. }
  20. EOF;
  21. file_put_contents("$path/{$this->profile}.install", $contents);
  22. parent::visitInstaller();
  23. }
  24. /**
  25. * Installer step: Configure settings.
  26. */
  27. protected function setUpSettings() {
  28. // There are errors therefore there is nothing to do here.
  29. return;
  30. }
  31. /**
  32. * Final installer step: Configure site.
  33. */
  34. protected function setUpSite() {
  35. // There are errors therefore there is nothing to do here.
  36. return;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. protected function getConfigTarball() {
  42. // We're not going to get to the config import stage so this does not
  43. // matter.
  44. return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config.tar.gz';
  45. }
  46. /**
  47. * Confirms the installation has failed and the expected error is displayed.
  48. */
  49. public function testConfigSync() {
  50. $this->assertTitle('Requirements problem | Drupal');
  51. $this->assertText($this->profile);
  52. $this->assertText('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.');
  53. }
  54. }