];
// Create a "reserved" template. This is a pristine copy provided for reference.
- MessageTemplate::create(FALSE)
- ->setValues([
- 'values' => $baseTpl + ['is_reserved' => 1, 'is_default' => 0],
- ]);
-
- // Create a default template. This is live. The administrator may edit/customize.
- MessageTemplate::create(FALSE)
- ->setValues([
- 'values' => $baseTpl + ['is_reserved' => 0, 'is_default' => 1],
- ]);
+ MessageTemplate::save(FALSE)
+ ->setDefaults($baseTpl)
+ ->setRecords([
+ ['is_reserved' => TRUE, 'is_default' => FALSE],
+ ['is_reserved' => FALSE, 'is_default' => TRUE],
+ ])
+ ->execute()->getArrayCopy();
}
// Check the message template generation
$token = \Civi\Api4\Action\User\SendPasswordReset::updateToken($userID);
$workflow = $security->preparePasswordResetWorkflow($user, $token);
+ $this->assertNotNull($workflow);
$result = $workflow->renderTemplate();
- $this->assertStringContainsString($token, $result['text']);
- $this->assertStringContainsString(htmlspecialchars($token), $result['html']);
- $this->assertEquals('x', $result['subject']);
+ $this->assertMatchesRegularExpression(';https?://[^/]+/civicrm/login/password.*' . $token . ';', $result['text']);
+ $this->assertMatchesRegularExpression(';https?://[^/]+/civicrm/login/password.*' . $token . ';', $result['html']);
+ $this->assertEquals('Password reset link for Demonstrators Anonymous', $result['subject']);
}
protected function deleteStuffWeMade() {