diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 044353c0ae..1eecc84979 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -152,10 +152,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#required' => TRUE, '#weight' => -20, ]; + $default_site_mail = $this->config('system.site')->get('mail'); $form['site_information']['site_mail'] = [ '#type' => 'email', '#title' => $this->t('Site email address'), - '#default_value' => ini_get('sendmail_from'), + '#default_value' => empty($default_site_mail) ? ini_get('sendmail_from') : $default_site_mail, '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."), '#required' => TRUE, '#weight' => -15, diff --git a/core/modules/system/src/Tests/Installer/InstallerSiteConfigDefaultTest.php b/core/modules/system/src/Tests/Installer/InstallerSiteConfigDefaultTest.php index 1b2021ec6e..1117bea095 100644 --- a/core/modules/system/src/Tests/Installer/InstallerSiteConfigDefaultTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerSiteConfigDefaultTest.php @@ -5,16 +5,28 @@ use Drupal\simpletest\InstallerTestBase; /** - * Verifies that the installer defaults to using the system timezone. + * Verifies that the installer defaults to using the system email address and + * timezone. * * @group Installer */ class InstallerSiteConfigDefaultTest extends InstallerTestBase { /** + * {@inheritdoc} + */ + protected function setUpSite() { + $this->assertFieldByName('site_mail', ini_get('sendmail_from')); + $this->assertFieldByName('date_default_timezone', @date_default_timezone_get()); + + return parent::setUpSite(); + } + + /** * Verify the correct site config was set. */ public function testInstaller() { + $this->assertEqual(\Drupal::config('system.site')->get('mail'), $this->parameters['forms']['install_configure_form']['site_mail']); $this->assertEqual(\Drupal::config('system.date')->get('timezone.default'), @date_default_timezone_get()); } diff --git a/core/modules/system/src/Tests/Installer/InstallerSiteConfigProfileTest.php b/core/modules/system/src/Tests/Installer/InstallerSiteConfigProfileTest.php index 588bd2e93f..421cb48936 100644 --- a/core/modules/system/src/Tests/Installer/InstallerSiteConfigProfileTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerSiteConfigProfileTest.php @@ -13,31 +13,49 @@ class InstallerSiteConfigProfileTest extends InstallerTestBase { protected $profile = 'testing_site_config'; + protected $profile_site_mail = 'profile-testing-site-config@example.com'; + protected $profile_timezone; + + public function __construct($test_id = NULL) { + parent::__construct($test_id); + + // The install profile set the timezone to one of two possibilities, but + // never to the system timezone. (See testing_site_config.install.) + $this->profile_timezone = 'America/Los_Angeles'; + if ($this->profile_timezone == @date_default_timezone_get()) { + $this->profile_timezone = 'America/New_York'; + } + } /** * {@inheritdoc} */ - protected function installParameters() { + protected function installParameters() { $parameters = parent::installParameters(); - // Don't override the site email address, which will default to the one from - // our install profile. + // Don't override the site email address, allowing it to default to the one + // from our install profile. unset($parameters['forms']['install_configure_form']['site_mail']); return $parameters; } /** + * {@inheritdoc} + */ + protected function setUpSite() { + $this->assertFieldByName('site_mail', $this->profile_site_mail); + $this->assertFieldByName('date_default_timezone', $this->profile_timezone); + + return parent::setUpSite(); + } + + /** * Verify the correct site config was set. */ public function testInstaller() { - $this->assertEqual(\Drupal::config('system.site')->get('mail'), 'profile-testing-site-config@example.com'); - - // The install profile set the timezone to one of two possibilities, but - // never to the system timezone. - $timezone = \Drupal::config('system.date')->get('timezone.default'); - $this->assertNotEqual($timezone, @date_default_timezone_get()); - $this->assertTrue($timezone == 'America/Los_Angeles' || $timezone == 'America/New_York', 'Timezone is either Los Angeles or New York.'); + $this->assertEqual(\Drupal::config('system.site')->get('mail'), $this->profile_site_mail); + $this->assertEqual(\Drupal::config('system.date')->get('timezone.default'), $this->profile_timezone); } }