DomainTokens - {domain.now} should abide by mocked times
authorTim Otten <totten@civicrm.org>
Tue, 21 Sep 2021 08:47:08 +0000 (01:47 -0700)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 22 Sep 2021 00:32:35 +0000 (12:32 +1200)
CRM/Core/DomainTokens.php

index a79368e301befe38e2a92ba6228508320d01270f..fe7384270bef950898ba84e09d58867a5b837cc9 100644 (file)
@@ -57,7 +57,8 @@ class CRM_Core_DomainTokens extends AbstractTokenSubscriber {
    */
   public function evaluateToken(TokenRow $row, $entity, $field, $prefetch = NULL): void {
     if ($field === 'now') {
-      $row->format('text/html')->tokens($entity, $field, new DateTime());
+      $nowObj = (new \DateTime())->setTimestamp(\CRM_Utils_Time::time());
+      $row->format('text/html')->tokens($entity, $field, $nowObj);
       return;
     }
     $row->format('text/html')->tokens($entity, $field, self::getDomainTokenValues()[$field]);