From 8ff9fbae60c78daede67cf7dff14111c84c899b4 Mon Sep 17 00:00:00 2001 From: wanshan Date: Tue, 25 Nov 2025 09:53:10 +0800 Subject: [PATCH] * [task#152995,doing,0.1h] add ui test for story module sendmail --- .../story/test/lib/ui/sendmail.ui.class.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/module/story/test/lib/ui/sendmail.ui.class.php b/module/story/test/lib/ui/sendmail.ui.class.php index 359398cc1b..5ead29d7af 100644 --- a/module/story/test/lib/ui/sendmail.ui.class.php +++ b/module/story/test/lib/ui/sendmail.ui.class.php @@ -14,7 +14,7 @@ class SendmailTester extends tester private function renderStoryMail($story) { global $app; - // 以下两个变量在sendmail.html.php模板中会被使用 + // 以下两个变量在sendmail.html.php模板中会被使用 $this->app = $app; $object = $story; @@ -55,13 +55,13 @@ class SendmailTester extends tester */ 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; + $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, 'success('需求邮件链接功能验证成功'); return $this->failed('需求邮件链接生成失败'); } @@ -78,13 +78,15 @@ class SendmailTester extends tester $mailModel = $uiTester->loadModel('mail'); $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_HOST'] ?? 'localhost'; if(!isset($mailModel->config->mail)) $mailModel->config->mail = new stdclass(); + $mailModel->config->mail->domain = rtrim($this->domain ?? 'http://localhost', '/'); - $mailModel->config->webRoot = '/'; - $mailModel->config->requestType = 'PATH_INFO'; + $mailModel->config->webRoot = '/'; + $mailModel->config->requestType = 'PATH_INFO'; + $object = $mailModel->getObjectForMail('story', (int)$story->id); if(!$object) { - $object = new stdclass(); + $object = new stdclass(); $object->type = 'story'; $object->id = (int)$story->id; $object->title = isset($story->title) ? $story->title : 'SendmailTest'; @@ -93,8 +95,8 @@ class SendmailTester extends tester } else $object->type = $object->type ?: 'story'; - $action = new stdClass(); - $action->id = 1; + $action = new stdClass(); + $action->id = 1; $action->action = 'created'; // 通过getMailContent方法获取邮件内容