Skip to content
Snippets Groups Projects
Commit 0f5e7931 authored by Simon Bäse's avatar Simon Bäse
Browse files

Issue #3528929 by simonbaese, anna d: Add generic module test for Symfony Mailer Queue

parent 42aae808
No related branches found
No related tags found
1 merge request!6Issue #3528929: Add generic module test for Symfony Mailer Queue
Pipeline #517484 passed
......@@ -33,7 +33,10 @@ function symfony_mailer_queue_help(string $route_name, RouteMatchInterface $rout
if ($route_name === 'help.page.symfony_mailer_queue') {
$output = '<h2>' . t('About') . '</h2>';
$output .= '<p>' . t('The <em>Symfony Mailer Queue</em> module extends the existing <a href=":symfony_mailer" title="Drupal Symfony Mailer">Drupal Symfony Mailer</a> module by integrating with queue systems to send emails. This enhancement ensures that email delivery is handled asynchronously, significantly improving the performance and reliability of your Drupal site. By utilizing Drupal’s queue system, the module processes email-sending tasks in the background, allowing for better resource management and scalability.', [':symfony_mailer' => 'https://www.drupal.org/project/symfony_mailer']) . '</p>';
$output .= '<p>' . t('The <em>Symfony Mailer Queue</em> module extends the existing <a href=":symfony_mailer" title="Drupal Symfony Mailer">Drupal Symfony Mailer</a> module by integrating with queue systems to send emails. This enhancement ensures that email delivery is handled asynchronously, significantly improving the performance and reliability of your Drupal site. By utilizing Drupal’s queue system, the module processes email-sending tasks in the background, allowing for better resource management and scalability. See the <a href=":symfony_mailer_queue">online documentation for the Symfony Mailer Queue module</a> for more details.', [
':symfony_mailer' => 'https://www.drupal.org/project/symfony_mailer',
':symfony_mailer_queue' => 'https://www.drupal.org/project/symfony_mailer_queue',
]) . '</p>';
$output .= '<h2>' . t('How to use?') . '</h2>';
$output .= '<ol>';
$output .= '<li>' . t('<strong>Configure Mailer Policies:</strong> Go to <em>Configuration > System > Mailer</em> and add the <em>Queue sending</em> email adjuster to the desired policies. Configure the queue behavior, requeue delay, maximum retry attempts, and wait time per item. When email processing fails, items that are immediately requeued become available for repeated processing right away. If requeuing is delayed, the item will only be available after the specified delay or once its lease time expires. While not all queue systems support delays, the Drupal database queue does. When using cron to process the queue, proper garbage collection to release items has then to be configured. For queues that do not support delays, a default lease time of one minute applies. Additionally, the email queue can be suspended, which requeues the failed item and delays the processing of other items until the next scheduled run.') . '</li>';
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\symfony_mailer_queue\Functional;
use Drupal\Tests\system\Functional\Module\GenericModuleTestBase;
/**
* Provides generic module tests for the Symfony mailer queue module.
*
* @coversNothing
* @group symfony_mailer_queue
*/
class GenericTest extends GenericModuleTestBase {}
<?php
declare(strict_types=1);
namespace Drupal\Tests\symfony_mailer_queue\Kernel;
use Drupal\Core\Queue\DelayableQueueInterface;
......@@ -37,15 +39,11 @@ class SymfonyMailerQueueBuildTest extends KernelTestBase {
/**
* The email factory.
*
* @var \Drupal\symfony_mailer\EmailFactoryInterface
*/
protected EmailFactoryInterface $emailFactory;
/**
* The Symfony mailer queue.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected QueueInterface $queue;
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\symfony_mailer_queue\Kernel;
use Drupal\Core\Queue\DelayableQueueInterface;
......@@ -53,15 +55,11 @@ class SymfonyMailerQueueTest extends KernelTestBase implements EventSubscriberIn
/**
* The email factory.
*
* @var \Drupal\symfony_mailer\EmailFactoryInterface
*/
protected EmailFactoryInterface $emailFactory;
/**
* The Symfony mailer queue.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected QueueInterface $queue;
......
......@@ -21,7 +21,7 @@ trait DelayableQueueRunnerTrait {
* @param string $queue_name
* The queue to process.
*/
protected function runQueue($queue_name): void {
protected function runQueue(string $queue_name): void {
$queue = $this->container->get('queue')->get($queue_name);
$worker = $this->container->get('plugin.manager.queue_worker')->createInstance($queue_name);
while ($item = $queue->claimItem()) {
......@@ -54,7 +54,7 @@ trait DelayableQueueRunnerTrait {
* @param string $queue_name
* The queue to process.
*/
protected function garbageCollectionForQueue($queue_name): void {
protected function garbageCollectionForQueue(string $queue_name): void {
$queue = $this->container->get('queue')->get($queue_name);
if ($queue instanceof QueueGarbageCollectionInterface) {
$queue->garbageCollection();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment