From: Tim Otten
{domain.address}{action.optOutUrl}
", + // 'body_html' => "Forward this emailForward this email with no protocol
This is {contact.display_name}.{domain.address}{action.optOutUrl}
", + 'body_html' => "This is {contact.display_name}.
{domain.address}{action.optOutUrl}
", 'name' => 'mailing name', 'created_id' => $this->_contactID, 'header_id' => '', @@ -287,15 +288,46 @@ class api_v3_MailingTest extends CiviUnitTestCase { $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_recipient records' $this->assertDBQuery($maxIDs['recipient'], 'SELECT MAX(id) FROM civicrm_mailing_recipients'); - $baseurl = CRM_Utils_System::baseCMSURL(); $previewResult = $result['values'][$result['id']]['api.Mailing.preview']; $this->assertEquals("Hello $displayName", $previewResult['values']['subject']); $this->assertStringContainsString("This is $displayName", $previewResult['values']['body_text']); $this->assertStringContainsString("This is $displayName.
", $previewResult['values']['body_html']); - $this->assertStringContainsString('Forward this email with no protocol', $previewResult['values']['body_html']); + $this->assertRegexp('!>Forward this email!', $previewResult['values']['body_html']); + $this->assertRegexp('!!', $previewResult['values']['body_html']); $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']); } + /** + * + */ + public function testMailerPreviewExtraScheme() { + try { + \Civi::settings()->set('flexmailer_traditional', 'bao'); + + $contactID = $this->individualCreate(); + $displayName = $this->callAPISuccess('contact', 'get', ['id' => $contactID]); + $displayName = $displayName['values'][$contactID]['display_name']; + $this->assertNotEmpty($displayName); + + $params = $this->_params; + $params['body_html'] = 'Forward this email written in ckeditor'; + $params['api.Mailing.preview'] = [ + 'id' => '$value.id', + 'contact_id' => $contactID, + ]; + $params['options']['force_rollback'] = 1; + + $result = $this->callAPISuccess('mailing', 'create', $params); + $previewResult = $result['values'][$result['id']]['api.Mailing.preview']; + $this->assertRegexp('!>Forward this email written in ckeditor!', $previewResult['values']['body_html']); + $this->assertRegexp('!!', $previewResult['values']['body_html']); + $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']); + + } finally { + \Civi::settings()->revert('flexmailer_traditional'); + } + } + public function testMailerPreviewUnknownContact(): void { $params = $this->_params; $params['api.Mailing.preview'] = [