chore(notice): 规范修复与安装演练收尾

This commit is contained in:
augushong
2026-10-12 13:40:40 +00:00
parent 3b6cb66549
commit a756b8a1cd
23 changed files with 978 additions and 981 deletions

View File

@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace tests\Feature;
use app\common\service\NoticeService;
use app\common\test\TestCase;
use base\common\notice\channel\EmailChannel;
use base\common\notice\channel\SmsChannel;
use base\common\notice\channel\WechatChannel;
use app\common\service\NoticeService;
use think\facade\Cache;
use think\facade\Db;
@@ -101,11 +101,11 @@ class NoticeChannelTest extends TestCase
private function setNotifyConfig(string $name, string $value): void
{
Db::name('system_config')->insert([
'name' => $name,
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeChannelTest fixture',
'sort' => 100,
'name' => $name,
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeChannelTest fixture',
'sort' => 100,
'create_time' => time(),
'update_time' => time(),
]);

View File

@@ -77,9 +77,9 @@ class NoticeEventTest extends TestCase
// inmail 行直接成功终态(无 email 地址的管理员 email 渠道被跳过)
$this->assertDatabaseHas('system_notice_target', [
'notice_id' => $row['id'],
'admin_id' => $adminId,
'channel' => 'inmail',
'status' => 2,
'admin_id' => $adminId,
'channel' => 'inmail',
'status' => 2,
]);
$this->assertSame(
1,
@@ -119,11 +119,11 @@ class NoticeEventTest extends TestCase
private function createAdmin(array $overrides = []): int
{
$data = array_merge([
'username' => 'evt_' . uniqid(),
'password' => 'not-a-real-password',
'nickname' => '事件测试用户',
'email' => '',
'status' => 1,
'username' => 'evt_' . uniqid(),
'password' => 'not-a-real-password',
'nickname' => '事件测试用户',
'email' => '',
'status' => 1,
'create_time' => time(),
'update_time' => time(),
'delete_time' => 0,
@@ -138,11 +138,11 @@ class NoticeEventTest extends TestCase
private function setLoginSceneSwitch(string $value): void
{
Db::name('system_config')->insert([
'name' => 'notify_login_scene_enable',
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeEventTest fixture',
'sort' => 100,
'name' => 'notify_login_scene_enable',
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeEventTest fixture',
'sort' => 100,
'create_time' => time(),
'update_time' => time(),
]);

View File

@@ -42,11 +42,11 @@ class NoticeServiceTest extends TestCase
$this->assertGreaterThan(0, $noticeId);
$this->assertDatabaseHas('system_notice', [
'id' => $noticeId,
'scene' => 'common',
'title' => '测试标题',
'content' => '测试内容',
'biz_id' => '',
'id' => $noticeId,
'scene' => 'common',
'title' => '测试标题',
'content' => '测试内容',
'biz_id' => '',
'send_admin_id' => 0,
]);
@@ -130,11 +130,11 @@ class NoticeServiceTest extends TestCase
$this->assertSame(2, Db::name('system_notice_target')
->where('notice_id', $noticeId)->where('admin_id', $adminWithMail)->count());
$this->assertDatabaseHas('system_notice_target', [
'notice_id' => $noticeId,
'admin_id' => $adminWithMail,
'channel' => 'email',
'notice_id' => $noticeId,
'admin_id' => $adminWithMail,
'channel' => 'email',
'target_addr' => 'scene@test.com',
'status' => 0,
'status' => 0,
]);
}
@@ -220,8 +220,8 @@ class NoticeServiceTest extends TestCase
$this->assertSame(1, Db::name('system_notice_target')->where('notice_id', $noticeId)->count());
$this->assertDatabaseHas('system_notice_target', [
'notice_id' => $noticeId,
'channel' => 'inmail',
'status' => 2,
'channel' => 'inmail',
'status' => 2,
]);
}
@@ -269,8 +269,8 @@ class NoticeServiceTest extends TestCase
$noticeId2 = NoticeService::send([$adminId], '总闸恢复', '内容');
$this->assertDatabaseHas('system_notice_target', [
'notice_id' => $noticeId2,
'channel' => 'inmail',
'status' => 2,
'channel' => 'inmail',
'status' => 2,
]);
}
@@ -348,11 +348,11 @@ class NoticeServiceTest extends TestCase
private function createAdmin(array $overrides = []): int
{
$data = array_merge([
'username' => 'ntc_' . uniqid(),
'password' => 'not-a-real-password',
'nickname' => '通知测试用户',
'email' => '',
'status' => 1,
'username' => 'ntc_' . uniqid(),
'password' => 'not-a-real-password',
'nickname' => '通知测试用户',
'email' => '',
'status' => 1,
'create_time' => time(),
'update_time' => time(),
'delete_time' => 0,
@@ -367,10 +367,10 @@ class NoticeServiceTest extends TestCase
private function insertSubscribe(int $adminId, string $scene, string $channel, int $status): void
{
Db::name('system_notice_subscribe')->insert([
'admin_id' => $adminId,
'scene' => $scene,
'channel' => $channel,
'status' => $status,
'admin_id' => $adminId,
'scene' => $scene,
'channel' => $channel,
'status' => $status,
'create_time' => time(),
'update_time' => time(),
]);
@@ -385,11 +385,11 @@ class NoticeServiceTest extends TestCase
private function setInmailSwitch(string $value): void
{
Db::name('system_config')->insert([
'name' => 'notify_inmail_enable',
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeServiceTest fixture',
'sort' => 100,
'name' => 'notify_inmail_enable',
'group' => 'notify',
'value' => $value,
'remark' => 'NoticeServiceTest fixture',
'sort' => 100,
'create_time' => time(),
'update_time' => time(),
]);