app = $app;
$object = $story;
global $config;
$domain = isset($config->mail->domain) && $config->mail->domain ? rtrim($config->mail->domain, '/') : 'http://localhost';
$this->domain = $domain;
// 使用ob_start和ob_get_contents来获取模板渲染后的内容
ob_start();
$templateFile = dirname(__FILE__, 4) . '/ui/sendmail.html.php';
if(file_exists($templateFile)) include $templateFile;
$mailContent = ob_get_contents();
ob_end_clean();
return $mailContent;
}
/**
* 测试需求邮件模板内容是否完整
* Test Story mail template content completeness
* @param $story storyModel
* @return object
*/
public function testTemplateContent($story)
{
$content = $this->renderStoryMail($story);
$mailTitle = 'STORY #' . $story->id . ' ' . $story->title;
$hasMailTitle = strpos($content, $mailTitle) !== false;
$hasSpec = strpos($content, $story->spec) !== false;
$hasTable = strpos($content, '
success('需求邮件模板内容验证成功');
return $this->failed('需求邮件模板内容不完整');
}
/**
* 测试需求邮件模板链接功能
* Test Story mail template link functionality
* @param $story storyModel
* @return object
*/
public function testLinkFunctionality($story)
{
$content = $this->renderStoryMail($story);
$expected = helper::createLink('story', 'view', "storyID={$story->id}", 'html');
$fullUrl = rtrim($this->domain ?? '', '/') . $expected;
$hasHref = strpos($content, 'href=') !== false;
$hasLegend = strpos($content, '