From e8c2c6f1bc8ffdea83b5b8952e51cebfc8de37df Mon Sep 17 00:00:00 2001 From: "lee.5151" <lee.5151@osu.edu> Date: Mon, 8 Jul 2024 12:16:05 -0400 Subject: [PATCH] Upgrading drupal/smtp (1.2.0 => 1.3.0) --- composer.json | 2 +- composer.lock | 22 +++--- vendor/composer/installed.json | 22 +++--- vendor/composer/installed.php | 10 +-- web/modules/smtp/.gitlab-ci.yml | 29 ++++++++ .../smtp/config/install/smtp.settings.yml | 1 + .../smtp/config/schema/smtp.schema.yml | 3 + web/modules/smtp/smtp.info.yml | 8 +-- web/modules/smtp/smtp.install | 9 +++ web/modules/smtp/smtp.module | 6 +- .../src/ConnectionTester/ConnectionTester.php | 2 +- web/modules/smtp/src/Form/SMTPConfigForm.php | 19 +++++ .../smtp/src/Plugin/Mail/SMTPMailSystem.php | 67 ++++++++++++++++-- .../ConnectionTester/ConnectionTesterTest.php | 2 +- .../Unit/Plugin/Mail/SMTPMailSystemTest.php | 70 ++++++++++++++++--- .../tests/src/Unit/SMTPConfigFormTest.php | 2 + 16 files changed, 222 insertions(+), 52 deletions(-) create mode 100644 web/modules/smtp/.gitlab-ci.yml diff --git a/composer.json b/composer.json index ab5058a338..3d3388d6d2 100644 --- a/composer.json +++ b/composer.json @@ -148,7 +148,7 @@ "drupal/scheduler": "2.0.4", "drupal/simple_gmap": "3.1.0", "drupal/simple_sitemap": "4.1.9", - "drupal/smtp": "1.2", + "drupal/smtp": "1.3", "drupal/social_media": "2.0.0", "drupal/social_media_links": "^2.8", "drupal/svg_image": "3.0.2", diff --git a/composer.lock b/composer.lock index 3d96c833a2..95fe59b03c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "99dc24e60634b6d9442ce25eb8d4c8f1", + "content-hash": "51a86303af247daee91a6f15f9f05dea", "packages": [ { "name": "algolia/places", @@ -5744,20 +5744,20 @@ }, { "name": "drupal/smtp", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/smtp.git", - "reference": "8.x-1.2" + "reference": "8.x-1.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.2.zip", - "reference": "8.x-1.2", - "shasum": "10d302d4a90521d674bdd078da8aed886fa5ec41" + "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.3.zip", + "reference": "8.x-1.3", + "shasum": "10c766f0a3ce588dc27d6ac2b21255a807be81d8" }, "require": { - "drupal/core": ">=8.9 <11", + "drupal/core": "^10.1 || ^11", "phpmailer/phpmailer": "^6.1.7" }, "suggest": { @@ -5766,8 +5766,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.2", - "datestamp": "1667416337", + "version": "8.x-1.3", + "datestamp": "1719260754", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -5790,10 +5790,6 @@ "name": "joseph.olstad", "homepage": "https://www.drupal.org/user/1321830" }, - { - "name": "josesanmartin", - "homepage": "https://www.drupal.org/user/72012" - }, { "name": "LukeLast", "homepage": "https://www.drupal.org/user/30151" diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c47b110063..15e0f805e4 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -6026,21 +6026,21 @@ }, { "name": "drupal/smtp", - "version": "1.2.0", - "version_normalized": "1.2.0.0", + "version": "1.3.0", + "version_normalized": "1.3.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/smtp.git", - "reference": "8.x-1.2" + "reference": "8.x-1.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.2.zip", - "reference": "8.x-1.2", - "shasum": "10d302d4a90521d674bdd078da8aed886fa5ec41" + "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.3.zip", + "reference": "8.x-1.3", + "shasum": "10c766f0a3ce588dc27d6ac2b21255a807be81d8" }, "require": { - "drupal/core": ">=8.9 <11", + "drupal/core": "^10.1 || ^11", "phpmailer/phpmailer": "^6.1.7" }, "suggest": { @@ -6049,8 +6049,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.2", - "datestamp": "1667416337", + "version": "8.x-1.3", + "datestamp": "1719260754", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -6071,8 +6071,8 @@ "homepage": "https://www.drupal.org/user/45640" }, { - "name": "josesanmartin", - "homepage": "https://www.drupal.org/user/72012" + "name": "joseph.olstad", + "homepage": "https://www.drupal.org/user/1321830" }, { "name": "LukeLast", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 7e5fda48c0..0a8153074b 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '6877cfc0e77a628513ba677a59cf65fa63a22872', + 'reference' => '360e7e8f7704019deb9720c254e5336a29f0b32f', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -1025,9 +1025,9 @@ 'dev_requirement' => false, ), 'drupal/smtp' => array( - 'pretty_version' => '1.2.0', - 'version' => '1.2.0.0', - 'reference' => '8.x-1.2', + 'pretty_version' => '1.3.0', + 'version' => '1.3.0.0', + 'reference' => '8.x-1.3', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/smtp', 'aliases' => array(), @@ -1519,7 +1519,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '6877cfc0e77a628513ba677a59cf65fa63a22872', + 'reference' => '360e7e8f7704019deb9720c254e5336a29f0b32f', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/web/modules/smtp/.gitlab-ci.yml b/web/modules/smtp/.gitlab-ci.yml new file mode 100644 index 0000000000..1afaac5b9f --- /dev/null +++ b/web/modules/smtp/.gitlab-ci.yml @@ -0,0 +1,29 @@ +################ +# GitLabCI template for Drupal projects. +# +# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. +# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained. +# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your +# pipelines automatically. However, you can modify this template if you have additional needs for your project. +# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/ +################ + +# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/ +# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml +include: + - project: $_GITLAB_TEMPLATES_REPO + ref: $_GITLAB_TEMPLATES_REF + file: + - "/includes/include.drupalci.main.yml" + - "/includes/include.drupalci.variables.yml" + - "/includes/include.drupalci.workflows.yml" + +################ +# Pipeline configuration variables are defined with default values and descriptions in the file +# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml +# Uncomment the lines below if you want to override any of the variables. The following is just an example. +################ +# variables: +# SKIP_ESLINT: '1' +# OPT_IN_TEST_NEXT_MAJOR: '1' +# _CURL_TEMPLATES_REF: 'main' \ No newline at end of file diff --git a/web/modules/smtp/config/install/smtp.settings.yml b/web/modules/smtp/config/install/smtp.settings.yml index 4413ac533b..165491b593 100644 --- a/web/modules/smtp/config/install/smtp.settings.yml +++ b/web/modules/smtp/config/install/smtp.settings.yml @@ -15,5 +15,6 @@ smtp_allowhtml: '' smtp_test_address: '' smtp_reroute_address: '' smtp_debugging: false +smtp_debug_level: 1 prev_mail_system: 'php_mail' smtp_keepalive: false diff --git a/web/modules/smtp/config/schema/smtp.schema.yml b/web/modules/smtp/config/schema/smtp.schema.yml index f80fa06c04..67a4eb8b78 100644 --- a/web/modules/smtp/config/schema/smtp.schema.yml +++ b/web/modules/smtp/config/schema/smtp.schema.yml @@ -53,6 +53,9 @@ smtp.settings: smtp_debugging: type: boolean label: 'Enable debugging' + smtp_debug_level: + type: integer + label: 'Debug level' prev_mail_system: type: string label: 'Previous mail system' diff --git a/web/modules/smtp/smtp.info.yml b/web/modules/smtp/smtp.info.yml index 9cb1d81c08..8f1bb2463e 100644 --- a/web/modules/smtp/smtp.info.yml +++ b/web/modules/smtp/smtp.info.yml @@ -2,10 +2,10 @@ name: SMTP Authentication Support description: "Allow for site emails to be sent through an SMTP server of your choice." package: Mail type: module -core_version_requirement: '>=8.9 <11' +core_version_requirement: ^10.1 || ^11 configure: smtp.config -# Information added by Drupal.org packaging script on 2022-11-02 -version: '8.x-1.2' +# Information added by Drupal.org packaging script on 2024-06-24 +version: '8.x-1.3' project: 'smtp' -datestamp: 1667416338 +datestamp: 1719254620 diff --git a/web/modules/smtp/smtp.install b/web/modules/smtp/smtp.install index 1201527fcd..77231d10cf 100644 --- a/web/modules/smtp/smtp.install +++ b/web/modules/smtp/smtp.install @@ -49,6 +49,15 @@ function smtp_update_8004() { } } +/** + * Add SMTP debug level and set default to 1. + */ +function smtp_update_8005() { + \Drupal::configFactory()->getEditable('smtp.settings') + ->set('smtp_debug_level', 1) + ->save(TRUE); +} + /** * Implements hook_requirements(). */ diff --git a/web/modules/smtp/smtp.module b/web/modules/smtp/smtp.module index 9566e9f1a0..21ca4bd8f1 100644 --- a/web/modules/smtp/smtp.module +++ b/web/modules/smtp/smtp.module @@ -97,6 +97,7 @@ function _smtp_mailer_send(array $variables) { $mailer = $variables['mailer']; $to = $variables['to']; $from = $variables['from']; + $system = $variables['mail_system']; $logger = \Drupal::logger('smtp'); @@ -107,7 +108,7 @@ function _smtp_mailer_send(array $variables) { try { $mailer->Send(); } - catch (Exception $e) { + catch (\Exception $e) { $logger->error('Error sending e-mail from @from to @to: @error_message', [ '@from' => $from, '@to' => $to, @@ -115,6 +116,9 @@ function _smtp_mailer_send(array $variables) { ]); return FALSE; } + finally { + $system->debug(); + } if (!$smtp_config->get('smtp_keepalive')) { $mailer->SmtpClose(); diff --git a/web/modules/smtp/src/ConnectionTester/ConnectionTester.php b/web/modules/smtp/src/ConnectionTester/ConnectionTester.php index 8b053cfa4b..8af7d0cd55 100644 --- a/web/modules/smtp/src/ConnectionTester/ConnectionTester.php +++ b/web/modules/smtp/src/ConnectionTester/ConnectionTester.php @@ -109,7 +109,7 @@ public function testConnection() { $smtp_enabled = $this->smtpConfig->get('smtp_on'); // Check to see if MailSystem is enabled and is using SMTPMailSystem. if (\Drupal::moduleHandler()->moduleExists('mailsystem')) { - $mailsystem_defaults = $this->configFactory->get('mailsystem.settings')->get('defaults'); + $mailsystem_defaults = (array) $this->configFactory->get('mailsystem.settings')->get('defaults'); $smtp_enabled = in_array('SMTPMailSystem', $mailsystem_defaults); } diff --git a/web/modules/smtp/src/Form/SMTPConfigForm.php b/web/modules/smtp/src/Form/SMTPConfigForm.php index b90178d6ab..5223eb5eff 100644 --- a/web/modules/smtp/src/Form/SMTPConfigForm.php +++ b/web/modules/smtp/src/Form/SMTPConfigForm.php @@ -325,6 +325,24 @@ public function buildForm(array $form, FormStateInterface $form_state) { <br /><strong>Warning!</strong> Debugging interrupts the request and will cause AJAX, Batch, and other operations to fail. Use in test environments only.'), '#disabled' => $this->isOverridden('smtp_debugging'), ]; + $form['smtp_debug_level'] = [ + '#type' => 'select', + '#title' => $this->t('Debug level'), + '#options' => [ + 1 => $this->t('Debug client'), + 2 => $this->t('Debug server'), + 3 => $this->t('Debug connection'), + 4 => $this->t('Debug lowlevel'), + ], + '#default_value' => $config->get('smtp_debug_level'), + '#description' => $this->t('Choose the appropriate log level.'), + '#disabled' => $this->isOverridden('smtp_debug_level'), + '#states' => [ + 'visible' => [ + ':input[name="smtp_debugging"]' => ['checked' => TRUE], + ], + ], + ]; $form['server']['smtp_keepalive'] = [ '#type' => 'checkbox', @@ -430,6 +448,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { 'smtp_test_address', 'smtp_reroute_address', 'smtp_debugging', + 'smtp_debug_level', 'smtp_keepalive', ]; foreach ($config_keys as $name) { diff --git a/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php b/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php index cf10c42394..e306a2db02 100644 --- a/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php +++ b/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php @@ -18,6 +18,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Session\AccountProxyInterface; +use Drupal\Core\Render\RendererInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * Modify the drupal mail system to use smtp when sending emails. @@ -82,7 +84,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { /** * The file mime type guesser service. * - * @var \Symfony\Component\Mime\MimeTypeGuesserInterface|\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface + * @var \Symfony\Component\Mime\MimeTypeGuesserInterface|\Symfony\Component\Mime\MimeTypesInterface */ protected $mimeTypeGuesser; @@ -93,6 +95,20 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { */ protected $persistentSmtp; + /** + * The renderer. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + + /** + * The session object. + * + * @var \Symfony\Component\HttpFoundation\Session\SessionInterface + */ + protected $session; + /** * Constructs a SMPTMailSystem object. * @@ -114,8 +130,12 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { * The current user service. * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system service. - * @param \Symfony\Component\Mime\MimeTypeGuesserInterface|\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser + * @param \Symfony\Component\Mime\MimeTypeGuesserInterface|\Symfony\Component\Mime\MimeTypesInterface $mime_type_guesser * The file mime type guesser service. + * @param \Drupal\Core\Render\RendererInterface $renderer + * The renderer. + * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session + * The session. */ public function __construct(array $configuration, $plugin_id, @@ -126,7 +146,9 @@ public function __construct(array $configuration, ConfigFactoryInterface $config_factory, AccountProxyInterface $account, FileSystemInterface $file_system, - $mime_type_guesser) { + MimeTypeGuesserInterface $mime_type_guesser, + RendererInterface $renderer, + SessionInterface $session) { $this->smtpConfig = $config_factory->get('smtp.settings'); $this->logger = $logger; $this->messenger = $messenger; @@ -135,6 +157,8 @@ public function __construct(array $configuration, $this->currentUser = $account; $this->fileSystem = $file_system; $this->mimeTypeGuesser = $mime_type_guesser; + $this->renderer = $renderer; + $this->session = $session; } /** @@ -163,7 +187,9 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('config.factory'), $container->get('current_user'), $container->get('file_system'), - $container->get('file.mime_type.guesser') + $container->get('file.mime_type.guesser'), + $container->get('renderer'), + $container->get('session') ); } @@ -233,7 +259,15 @@ public function mail(array $message) { // Turn on debugging, if requested. if ($this->smtpConfig->get('smtp_debugging') && $this->currentUser->hasPermission('administer smtp module')) { - $mailer->SMTPDebug = TRUE; + $mailer->SMTPDebug = $this->smtpConfig->get('smtp_debug_level'); + $mailer->Debugoutput = function ($message, $debug_level) { + $debug_logs = $this->session->get('smtp_debug', []); + $debug_logs[] = [ + 'message' => $message, + 'level' => $debug_level, + ]; + $this->session->set('smtp_debug', $debug_logs); + }; } // Turn on KeepAlive feature if requested. @@ -638,7 +672,7 @@ public function mail(array $message) { } else { // @phpstan-ignore-next-line - $file_path = file_save_data($attachment, $attachment_new_filename, FileSystemInterface::EXISTS_REPLACE); + $file_path = \Drupal::service('file.repository')->writeData($attachment, $attachment_new_filename, FileSystemInterface::EXISTS_REPLACE); } $real_path = $this->fileSystem->realpath($file_path->uri); @@ -708,6 +742,7 @@ public function mail(array $message) { 'mailer' => $mailer, 'to' => $to, 'from' => $from, + 'mail_system' => $this, ]; if ($this->smtpConfig->get('smtp_queue')) { $logger->info($this->t('Queue sending mail to: @to (subject: %subject)', ['@to' => $to, '%subject' => $subject])); @@ -935,4 +970,24 @@ protected function getMailer() { } } + /** + * Log debug messages. + */ + public function debug() { + $logger = $this->logger->get('smtp'); + $debug_logs = $this->session->get('smtp_debug', []); + if ($this->smtpConfig->get('smtp_debugging') && $this->currentUser->hasPermission('administer smtp module') && !empty($debug_logs)) { + $item_list = [ + '#theme' => 'item_list', + '#items' => [], + ]; + foreach ($debug_logs as $debug_log) { + $item_list['#items'][] = $debug_log['message']; + } + $debug_logs_message = $this->renderer->render($item_list); + $logger->log('debug', $debug_logs_message); + $this->session->remove('smtp_debug'); + } + } + } diff --git a/web/modules/smtp/tests/src/Kernel/ConnectionTester/ConnectionTesterTest.php b/web/modules/smtp/tests/src/Kernel/ConnectionTester/ConnectionTesterTest.php index c7365b125e..0f3383cbd3 100644 --- a/web/modules/smtp/tests/src/Kernel/ConnectionTester/ConnectionTesterTest.php +++ b/web/modules/smtp/tests/src/Kernel/ConnectionTester/ConnectionTesterTest.php @@ -61,7 +61,7 @@ public function testHookRequirements(string $message, bool $smtp_on, bool $resul /** * Provider for testHookRequirements(). */ - public function providerHookRequirements() { + public static function providerHookRequirements() { return [ [ 'message' => 'SMTP on, working.', diff --git a/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php b/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php index 8f42ccadea..0da993d1a7 100644 --- a/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php +++ b/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php @@ -21,6 +21,8 @@ use Prophecy\Argument; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Mime\MimeTypeGuesserInterface; +use Drupal\Core\Render\RendererInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * Validate requirements for SMTPMailSystem. @@ -41,6 +43,7 @@ class SMTPMailSystemTest extends UnitTestCase { * {@inheritdoc} */ protected function setUp(): void { + parent::setUp(); $this->mockConfigFactory = $this->getConfigFactoryStub([ 'smtp.settings' => [ 'smtp_timeout' => 30, @@ -60,6 +63,8 @@ protected function setUp(): void { $this->mockCurrentUser = $this->prophesize(AccountProxy::class); $this->mockFileSystem = $this->prophesize(FileSystem::class); $this->mimeTypeGuesser = $this->prophesize(MimeTypeGuesser::class); + $this->mockRender = $this->prophesize(RendererInterface::class); + $this->mockSession = $this->prophesize(SessionInterface::class); $mockContainer = $this->mockContainer = $this->prophesize(ContainerInterface::class); $mockContainer->get('config.factory')->willReturn($this->mockConfigFactory); @@ -68,6 +73,8 @@ protected function setUp(): void { $mockContainer->get('current_user')->willReturn($this->mockCurrentUser->reveal()); $mockContainer->get('file_system')->willReturn($this->mockFileSystem->reveal()); $mockContainer->get('file.mime_type.guesser')->willReturn($this->mimeTypeGuesser->reveal()); + $mockContainer->get('renderer')->willReturn($this->mockRender->reveal()); + $mockContainer->get('session')->willReturn($this->mockSession->reveal()); $mockStringTranslation = $this->prophesize(TranslationInterface::class); $mockStringTranslation->translate(Argument::any())->willReturnArgument(0); @@ -84,7 +91,7 @@ protected function setUp(): void { /** * Provides scenarios for getComponents(). */ - public function getComponentsProvider() { + public static function getComponentsProvider() { return [ [ // Input. @@ -141,7 +148,20 @@ public function getComponentsProvider() { * @dataProvider getComponentsProvider */ public function testGetComponents($input, $expected) { - $mailSystem = new SMTPMailSystemTestHelper([], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), $this->emailValidator, $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), $this->mimeTypeGuesser->reveal()); + $mailSystem = new SMTPMailSystemTestHelper( + [], + '', + [], + $this->mockLogger->reveal(), + $this->mockMessenger->reveal(), + $this->emailValidator, + $this->mockConfigFactory, + $this->mockCurrentUser->reveal(), + $this->mockFileSystem->reveal(), + $this->mimeTypeGuesser->reveal(), + $this->mockRender->reveal(), + $this->mockSession->reveal() + ); $ret = $mailSystem->publicGetComponents($input); @@ -160,7 +180,20 @@ public function testGetComponents($input, $expected) { * Test applyRerouting(). */ public function testApplyRerouting() { - $mailSystemRerouted = new SMTPMailSystemTestHelper([], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), $this->emailValidator, $this->mockConfigFactoryRerouted, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), $this->mimeTypeGuesser->reveal()); + $mailSystemRerouted = new SMTPMailSystemTestHelper( + [], + '', + [], + $this->mockLogger->reveal(), + $this->mockMessenger->reveal(), + $this->emailValidator, + $this->mockConfigFactoryRerouted, + $this->mockCurrentUser->reveal(), + $this->mockFileSystem->reveal(), + $this->mimeTypeGuesser->reveal(), + $this->mockRender->reveal(), + $this->mockSession->reveal(), + ); $to = 'abc@example.com'; $headers = [ 'some' => 'header', @@ -171,7 +204,20 @@ public function testApplyRerouting() { $this->assertEquals($new_to, 'blackhole@galaxy.com', 'to address is set to the reroute address.'); $this->assertEquals($new_headers, ['some' => 'header'], 'bcc and cc headers are unset when rerouting.'); - $mailSystemNotRerouted = new SMTPMailSystemTestHelper([], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), $this->emailValidator, $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), $this->mimeTypeGuesser->reveal()); + $mailSystemNotRerouted = new SMTPMailSystemTestHelper( + [], + '', + [], + $this->mockLogger->reveal(), + $this->mockMessenger->reveal(), + $this->emailValidator, + $this->mockConfigFactory, + $this->mockCurrentUser->reveal(), + $this->mockFileSystem->reveal(), + $this->mimeTypeGuesser->reveal(), + $this->mockRender->reveal(), + $this->mockSession->reveal(), + ); $to = 'abc@example.com'; $headers = [ 'some' => 'header', @@ -186,7 +232,7 @@ public function testApplyRerouting() { /** * Provides scenarios for testMailValidator(). */ - public function mailValidatorProvider() { + public static function mailValidatorProvider() { $emailValidatorPhpMailerDefault = new EmailValidatorPhpMailerDefault(); $emailValidatorDrupal = new EmailValidator(); return [ @@ -259,7 +305,9 @@ public function testMailValidator(string $to, string $from, EmailValidatorInterf $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), - $this->mimeTypeGuesser->reveal() + $this->mimeTypeGuesser->reveal(), + $this->mockRender->reveal(), + $this->mockSession->reveal() ); $message = [ 'to' => $to, @@ -292,11 +340,13 @@ public function testMailHeader() { [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), - new EmailValidatorPhpMailerDefault(), + $this->emailValidator, $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), - $this->mimeTypeGuesser->reveal() + $this->mimeTypeGuesser->reveal(), + $this->mockRender->reveal(), + $this->mockSession->reveal(), ); $message = [ @@ -339,7 +389,9 @@ public function testFromHeaders_3308653() { ]), $this->createMock(AccountProxyInterface::class), $this->createMock(FileSystemInterface::class), - $this->createMock(MimeTypeGuesserInterface::class) + $this->createMock(MimeTypeGuesserInterface::class), + $this->createMock(RendererInterface::class), + $this->createMock(SessionInterface::class) ) extends SMTPMailSystem { /** diff --git a/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php b/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php index 3179c73084..ed60a08391 100644 --- a/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php +++ b/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php @@ -29,6 +29,7 @@ class SMTPConfigFormTest extends UnitTestCase { * Test setup. */ public function setup(): void { + parent::setup(); $this->mockConfigFactory = $this->prophesize(ConfigFactoryInterface::class); $this->mockConfig = $this->prophesize(Config::class); $this->mockConfigFactory->get('smtp.settings')->willReturn($this->mockConfig->reveal()); @@ -80,6 +81,7 @@ public function setDefaultConfig() { $this->mockConfig->get('smtp_client_hostname')->willReturn(''); $this->mockConfig->get('smtp_client_helo')->willReturn(''); $this->mockConfig->get('smtp_debugging')->willReturn(''); + $this->mockConfig->get('smtp_debug_level')->willReturn(1); $this->mockConfig->get('smtp_keepalive')->willReturn(FALSE); $this->mockConfig->get('smtp_reroute_address')->willReturn(''); } -- GitLab