InstallerTest.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * Ensures that the user page is available after installation.
  11. */
  12. public function testInstaller() {
  13. $this->assertUrl('user/1');
  14. $this->assertResponse(200);
  15. // Confirm that we are logged-in after installation.
  16. $this->assertText($this->rootUser->getUsername());
  17. // Verify that the confirmation message appears.
  18. require_once $this->root . '/core/includes/install.inc';
  19. $this->assertRaw(t('Congratulations, you installed @drupal!', [
  20. '@drupal' => drupal_install_profile_distribution_name(),
  21. ]));
  22. // Ensure that the timezone is correct for sites under test after installing
  23. // interactively.
  24. $this->assertEqual($this->config('system.date')->get('timezone.default'), 'Australia/Sydney');
  25. }
  26. /**
  27. * Installer step: Select language.
  28. */
  29. protected function setUpLanguage() {
  30. // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets and
  31. // metatags as expected to the first page of the installer.
  32. $this->assertRaw("core/themes/seven/css/components/buttons.css");
  33. $this->assertRaw('<meta charset="utf-8" />');
  34. // Assert that the expected title is present.
  35. $this->assertEqual('Choose language', $this->cssSelect('main h2')[0]->getText());
  36. parent::setUpLanguage();
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. protected function setUpProfile() {
  42. // Assert that the expected title is present.
  43. $this->assertEqual('Select an installation profile', $this->cssSelect('main h2')[0]->getText());
  44. $result = $this->xpath('//span[contains(@class, :class) and contains(text(), :text)]', [':class' => 'visually-hidden', ':text' => 'Select an installation profile']);
  45. $this->assertEqual(count($result), 1, "Title/Label not displayed when '#title_display' => 'invisible' attribute is set");
  46. parent::setUpProfile();
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. protected function setUpSettings() {
  52. // Assert that the expected title is present.
  53. $this->assertEqual('Database configuration', $this->cssSelect('main h2')[0]->getText());
  54. parent::setUpSettings();
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. protected function setUpSite() {
  60. // Assert that the expected title is present.
  61. $this->assertEqual('Configure site', $this->cssSelect('main h2')[0]->getText());
  62. // Test that SiteConfigureForm::buildForm() has made the site directory and
  63. // the settings file non-writable.
  64. $site_directory = $this->container->get('app.root') . '/' . $this->siteDirectory;
  65. $this->assertFalse(is_writable($site_directory));
  66. $this->assertFalse(is_writable($site_directory . '/settings.php'));
  67. parent::setUpSite();
  68. }
  69. /**
  70. * {@inheritdoc}
  71. */
  72. protected function visitInstaller() {
  73. parent::visitInstaller();
  74. // Assert the title is correct and has the title suffix.
  75. $this->assertTitle('Choose language | Drupal');
  76. }
  77. }