InstallerTest.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. /**
  4. * Tests the interactive installer.
  5. *
  6. * @group Installer
  7. */
  8. class InstallerTest extends InstallerTestBase {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. protected $defaultTheme = 'stark';
  13. /**
  14. * Ensures that the user page is available after installation.
  15. */
  16. public function testInstaller() {
  17. $this->assertUrl('user/1');
  18. $this->assertSession()->statusCodeEquals(200);
  19. // Confirm that we are logged-in after installation.
  20. $this->assertText($this->rootUser->getAccountName());
  21. // Verify that the confirmation message appears.
  22. require_once $this->root . '/core/includes/install.inc';
  23. $this->assertRaw(t('Congratulations, you installed @drupal!', [
  24. '@drupal' => drupal_install_profile_distribution_name(),
  25. ]));
  26. // Ensure that the timezone is correct for sites under test after installing
  27. // interactively.
  28. $this->assertEqual($this->config('system.date')->get('timezone.default'), 'Australia/Sydney');
  29. // Ensure the profile has a weight of 1000.
  30. $module_extension_list = \Drupal::service('extension.list.module');
  31. $extensions = $module_extension_list->getList();
  32. $this->assertArrayHasKey('testing', $extensions);
  33. $this->assertEquals(1000, $extensions['testing']->weight);
  34. }
  35. /**
  36. * Installer step: Select language.
  37. */
  38. protected function setUpLanguage() {
  39. // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets and
  40. // metatags as expected to the first page of the installer.
  41. $this->assertRaw("core/themes/seven/css/components/buttons.css");
  42. $this->assertRaw('<meta charset="utf-8" />');
  43. // Assert that the expected title is present.
  44. $this->assertEqual('Choose language', $this->cssSelect('main h2')[0]->getText());
  45. parent::setUpLanguage();
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. protected function setUpProfile() {
  51. // Assert that the expected title is present.
  52. $this->assertEqual('Select an installation profile', $this->cssSelect('main h2')[0]->getText());
  53. $result = $this->xpath('//span[contains(@class, :class) and contains(text(), :text)]', [':class' => 'visually-hidden', ':text' => 'Select an installation profile']);
  54. $this->assertCount(1, $result, "Title/Label not displayed when '#title_display' => 'invisible' attribute is set");
  55. parent::setUpProfile();
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. protected function setUpSettings() {
  61. // Assert that the expected title is present.
  62. $this->assertEqual('Database configuration', $this->cssSelect('main h2')[0]->getText());
  63. // Assert that we use the by core supported database drivers by default and
  64. // not the ones from the driver_test module.
  65. $elements = $this->xpath('//label[@for="edit-driver-mysql"]');
  66. $this->assertEqual(current($elements)->getText(), 'MySQL, MariaDB, Percona Server, or equivalent');
  67. $elements = $this->xpath('//label[@for="edit-driver-pgsql"]');
  68. $this->assertEqual(current($elements)->getText(), 'PostgreSQL');
  69. parent::setUpSettings();
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. protected function setUpSite() {
  75. // Assert that the expected title is present.
  76. $this->assertEqual('Configure site', $this->cssSelect('main h2')[0]->getText());
  77. // Test that SiteConfigureForm::buildForm() has made the site directory and
  78. // the settings file non-writable.
  79. $site_directory = $this->container->get('app.root') . '/' . $this->siteDirectory;
  80. $this->assertDirectoryNotIsWritable($site_directory);
  81. $this->assertFileNotIsWritable($site_directory . '/settings.php');
  82. parent::setUpSite();
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. protected function visitInstaller() {
  88. parent::visitInstaller();
  89. // Assert the title is correct and has the title suffix.
  90. $this->assertTitle('Choose language | Drupal');
  91. }
  92. }