+
+ $expectedEventString = $this->getExpectedEventTokenOutput();
+ $this->callAPISuccess('job', 'send_reminder', []);
+ $expectedParticipantString = $this->getExpectedParticipantTokenOutput();
+ $toCheck = array_merge(explode("\n", $expectedEventString), explode("\n", $expectedParticipantString));
+ $toCheck[] = $expectedEventString;
+ $toCheck[] = $expectedParticipantString;
+ $mut->checkMailLog($toCheck);
+ $tokens = array_keys($this->getEventTokens());
+ $html = $this->getTokenString($tokens);
+ $tokenProcessor->addMessage('html', $html, 'text/plain');
+ $tokenProcessor->addRow(['eventId' => $this->ids['event'][0]]);
+ $tokenProcessor->evaluate();
+ $this->assertEquals($expectedEventString, $tokenProcessor->getRow(0)->render('html'));
+ }
+
+ /**
+ * Test that event tokens work absent participant tokens.
+ *
+ * @throws \API_Exception
+ */
+ public function testEventTokenConsistencyNoParticipantTokens(): void {
+ $mut = new CiviMailUtils($this);
+ $this->setupParticipantScheduledReminder(FALSE);
+
+ $this->callAPISuccess('job', 'send_reminder', []);
+ $expected = $this->getExpectedEventTokenOutput();
+ // Checking these individually is easier to decipher discrepancies
+ // but we also want to check in entirety.
+ $toCheck = explode("\n", $expected);
+ $toCheck[] = $expected;
+ $mut->checkMailLog($toCheck);
+
+ $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [
+ 'controller' => __CLASS__,
+ 'smarty' => FALSE,
+ 'schema' => ['eventId'],
+ ]);
+ $html = $this->getTokenString(array_keys($this->getEventTokens()));
+
+ $tokenProcessor->addMessage('html', $html, 'text/plain');
+ $tokenProcessor->addRow(['eventId' => $this->ids['event'][0]]);
+ $tokenProcessor->evaluate();
+ $this->assertEquals($expected, $tokenProcessor->getRow(0)->render('html'));
+
+ }
+
+ /**
+ * Set up scheduled reminder for participants.
+ *
+ * @throws \API_Exception
+ */
+ public function setupParticipantScheduledReminder($includeParticipant = TRUE): void {
+ $this->createEventAndParticipant();
+ $tokens = array_keys($this->getEventTokens());
+ if ($includeParticipant) {
+ $tokens = array_keys(array_merge($this->getEventTokens(), $this->getParticipantTokens()));
+ }
+ $html = $this->getTokenString($tokens);
+ CRM_Utils_Time::setTime('2007-02-20 15:00:00');
+ $this->callAPISuccess('action_schedule', 'create', [
+ 'title' => 'job',
+ 'subject' => 'job',
+ 'entity_value' => 1,
+ 'mapping_id' => 2,
+ 'start_action_date' => 'register_date',
+ 'start_action_offset' => 1,
+ 'start_action_condition' => 'after',
+ 'start_action_unit' => 'day',
+ 'body_html' => $html,
+ ]);