InstallerExistingBrokenDatabaseSettingsTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Core\Database\Database;
  4. /**
  5. * Tests the installer with broken database connection info in settings.php.
  6. *
  7. * @group Installer
  8. */
  9. class InstallerExistingBrokenDatabaseSettingsTest extends InstallerTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. protected $defaultTheme = 'stark';
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected function prepareEnvironment() {
  18. parent::prepareEnvironment();
  19. // Pre-configure database credentials in settings.php.
  20. $connection_info = Database::getConnectionInfo();
  21. if ($connection_info['default']['driver'] !== 'mysql') {
  22. $this->markTestSkipped('This test relies on overriding the mysql driver');
  23. }
  24. // Use a database driver that reports a fake database version that does
  25. // not meet requirements.
  26. unset($connection_info['default']['pdo']);
  27. unset($connection_info['default']['init_commands']);
  28. $connection_info['default']['driver'] = 'DrivertestMysqlDeprecatedVersion';
  29. $namespace = 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion';
  30. $connection_info['default']['namespace'] = $namespace;
  31. $connection_info['default']['autoload'] = Database::findDriverAutoloadDirectory($namespace, \Drupal::root());
  32. $this->settings['databases']['default'] = (object) [
  33. 'value' => $connection_info,
  34. 'required' => TRUE,
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. protected function setUpSettings() {
  41. // This form will never be reached.
  42. return;
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. protected function setUpSite() {
  48. // This form will never be reached.
  49. return;
  50. }
  51. /**
  52. * Tests the expected requirements problem.
  53. */
  54. public function testRequirementsProblem() {
  55. $this->assertSession()->titleEquals('Requirements problem | Drupal');
  56. $this->assertSession()->pageTextContains('Database settings');
  57. $this->assertSession()->pageTextContains('Resolve all issues below to continue the installation. For help configuring your database server,');
  58. $this->assertSession()->pageTextContains('The database server version 5.5.2 is less than the minimum required version');
  59. }
  60. }