进行了一些小优化

This commit is contained in:
2026-08-25 05:59:50 +08:00
parent 5549f81901
commit 75d1e6e53b
7 changed files with 52 additions and 8 deletions
+18
View File
@@ -0,0 +1,18 @@
<?php
use AKSRT\Payment\Withdrawal;
use PHPUnit\Framework\TestCase;
final class WithdrawalTest extends TestCase {
public function test_account_display_mask_preserves_utf8_characters(): void {
$method = new ReflectionMethod(Withdrawal::class, 'normalize_row');
$row = $method->invoke(Withdrawal::get_instance(), [
'account_info' => wp_json_encode(['account' => '账户名称 账户号码']),
'gross_amount' => '100.00',
'amount' => '95.00',
]);
self::assertSame('账户*****号码', $row['display_account']);
self::assertSame(1, preg_match('//u', $row['display_account']));
}
}
+1
View File
@@ -70,3 +70,4 @@ require_once dirname(__DIR__, 2) . '/src/Ledger/LedgerCommand.php';
require_once dirname(__DIR__, 2) . '/src/Ledger/LedgerResult.php';
require_once dirname(__DIR__, 2) . '/src/Ledger/OperationKey.php';
require_once dirname(__DIR__, 2) . '/src/Finance/BusinessNumber.php';
require_once dirname(__DIR__, 2) . '/src/Payment/Withdrawal.php';
@@ -41,3 +41,15 @@ test('native and front-end surfaces expose immutable business numbers', () => {
assert.match(read('assets/js/order-center.js'), /\["流水号", order\.flow_number \|\| "—"\]/)
assert.match(read('inc/helpers/user-center-renderers/credits-wallet.php'), /withdrawal_number/)
})
test('balance history renders withdrawal numbers from the committed flow', () => {
const query = read('src/Ledger/LedgerQuery.php')
const profile = read('inc/helpers/user-center-renderers/profile-credits.php')
const wallet = read('inc/helpers/user-center-renderers/credits-wallet.php')
assert.match(query, /LEFT JOIN \{\$flow_table\} f ON f\.ledger_transaction_id = t\.id/)
assert.match(query, /'withdrawal_number'\s*=>\s*\(string\)/)
for (const source of [profile, wallet]) {
assert.match(source, /\['withdraw_hold', 'withdraw_refund'\]/)
assert.match(source, /\$row\['withdrawal_number'\]/)
}
})