You are here

protected function MessageDigestTrait::expireDigestMessages in Message Digest 8

Makes sure all digest messages will be sent out at the next cron run.

1 call to MessageDigestTrait::expireDigestMessages()
MessageDigestSubContext::deliverAllDigests in ./message_digest.behat.inc
Delivers all message digests.

File

src/Traits/MessageDigestTrait.php, line 45

Class

MessageDigestTrait
Methods useful for testing and integrating the Message Digest module.

Namespace

Drupal\message_digest\Traits

Code

protected function expireDigestMessages() {

  // Make sure all unsent messages have a timestamp 1 day in the past. Any
  // messages that are created during the test have a newer timestamp than the
  // request of the bootstrapped Drupal instance, causing them to be ignored
  // during sending.

  /** @var \Drupal\Core\Database\Connection $database */
  $database = \Drupal::service('database');
  $database
    ->update('message_digest')
    ->fields([
    'timestamp' => time() - 24 * 60 * 60,
  ])
    ->condition('sent', 0)
    ->execute();
}