'use strict'; const assert = require('node:assert/strict'); const { execFileSync } = require('node:child_process'); const fs = require('node:fs'); const path = require('node:path'); const test = require('node:test'); const root = path.join(__dirname, '..', '..'); test('WeChat business event mappings and hook registration', () => { const harness = path.join(__dirname, 'wechat-events-harness.php'); const output = execFileSync('php', [harness], { encoding: 'utf8' }); assert.match(output, /WeChat events harness passed/); }); test('business actions are emitted by the owning workflows', () => { const cases = [ ['src/Identity/ApplicationService.php', 'jio_auth_application_submitted'], ['src/User/AuthApply.php', 'jio_auth_application_reviewed'], ['inc/modules/user-parts/account-ajax.php', 'jio_user_email_changed'], ['inc/modules/user-notifications.php', 'jio_wechat_comment_postauthor'], ['inc/modules/user-notifications.php', 'jio_wechat_comment_parent'], ]; const adapter = fs.readFileSync(path.join(root, 'src/Payment/WeChatNotifyEvents.php'), 'utf8'); for (const [file, event] of cases) { const source = fs.readFileSync(path.join(root, file), 'utf8'); assert.ok(source.includes(`do_action('${event}'`), `${file} does not emit ${event}`); assert.ok(adapter.includes(`add_action('${event}'`), `adapter does not register ${event}`); } const restReports = fs.readFileSync(path.join(root, 'src/Admin/UserControllerReportOperations.php'), 'utf8'); assert.match(restReports, /\$status !== \(string\) \(\$row\['status'\] \?\? ''\)[\s\S]*?do_action\('jio_report_status_changed'/); });