fix(email): lock templates to built-in catalog
This commit is contained in:
@@ -8,6 +8,7 @@ const read = (file) => fs.readFileSync(path.join(root, file), 'utf8')
|
||||
|
||||
const templates = read('src/Settings/MailTemplates.php')
|
||||
const mail = read('src/Settings/Mail.php')
|
||||
const schemaProvider = read('src/Admin/SchemaProvider.php')
|
||||
const notifications = read('src/Settings/MailNotifications.php')
|
||||
const coreHooks = read('inc/core-hooks.php')
|
||||
const globalController = read('src/Admin/GlobalController.php')
|
||||
@@ -34,9 +35,10 @@ test('forum-only events stay out of the email catalog', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('email templates and SMTP use one aksrt_settings schema', () => {
|
||||
test('email settings keep one canonical SMTP schema', () => {
|
||||
assert.match(templates, /'option_key'\s*=>\s*'aksrt_settings'/)
|
||||
assert.match(templates, /'mail_passwd'.*'secret'\s*=>\s*true/)
|
||||
assert.match(templates, /'email_test_send'.*'ui_only'\s*=>\s*true/)
|
||||
assert.match(mail, /Settings::get_all\(\)/)
|
||||
assert.match(mail, /'auth'\s*=>\s*\$username\s*!==\s*''\s*&&\s*\$password\s*!==\s*''/)
|
||||
assert.doesNotMatch(templates, /mail_smtpauth/)
|
||||
@@ -46,6 +48,23 @@ test('email templates and SMTP use one aksrt_settings schema', () => {
|
||||
assert.doesNotMatch(userController, /aksrt_mail_templates|mail-templates/)
|
||||
})
|
||||
|
||||
test('email event schema exposes only notification switches', () => {
|
||||
assert.match(templates, /private static function event_group\([^)]*\): array/)
|
||||
assert.match(templates, /\$fields\[\] = \['key' => "email_\{\$event\}_enabled"/)
|
||||
assert.doesNotMatch(templates, /email_\{\$event\}_subject/)
|
||||
assert.doesNotMatch(templates, /email_\{\$event\}_content/)
|
||||
assert.doesNotMatch(templates, /email_[A-Za-z0-9_]+_(subject|content)/)
|
||||
assert.doesNotMatch(templates, /主题模板|正文模板|可用占位符/)
|
||||
assert.doesNotMatch(schemaProvider, /is_mail_template|email_.+_\(subject\|content\)/)
|
||||
})
|
||||
|
||||
test('mail runtime always uses the built-in event catalog', () => {
|
||||
assert.match(mail, /replace_placeholders\(\(string\) \$definition\['title'\], \$placeholders\)/)
|
||||
assert.match(mail, /replace_placeholders\(\(string\) \$definition\['content'\], \$placeholders\)/)
|
||||
assert.doesNotMatch(mail, /\$subject_key|\$content_key|default_subject|default_content/)
|
||||
assert.doesNotMatch(mail, /get_email_event_config\(\)/)
|
||||
})
|
||||
|
||||
test('SMTP authentication and failures use the canonical mail service', () => {
|
||||
assert.match(coreHooks, /add_filter\('wp_mail_from',/)
|
||||
assert.match(coreHooks, /add_filter\('wp_mail_from_name',/)
|
||||
|
||||
Reference in New Issue
Block a user