fix(user-center): 防止大额资产金额断行

This commit is contained in:
2026-09-16 17:23:56 +08:00
parent e7ffb44b45
commit 56d1b2a417
9 changed files with 59 additions and 5 deletions
+8
View File
@@ -73,4 +73,12 @@ final class AssetAmountTest extends TestCase {
$this->expectException(InvalidArgumentException::class);
AssetAmount::percentage(100, 101);
}
public function test_formatted_adds_thousands_separators_to_balance(): void {
self::assertSame('0.00', AssetAmount::balance('0')->formatted());
self::assertSame('12.34', AssetAmount::balance('12.34')->formatted());
self::assertSame('564,000.00', AssetAmount::balance('564000')->formatted());
self::assertSame('1,234,567.89', AssetAmount::balance('1234567.89')->formatted());
self::assertSame('37', AssetAmount::points(37)->formatted());
}
}
+5
View File
@@ -56,6 +56,11 @@ if (!function_exists('wp_is_uuid')) {
return $version === null || strtolower($matches[1]) === strtolower((string) $version);
}
}
if (!function_exists('number_format_i18n')) {
function number_format_i18n($number): string {
return number_format((float) $number);
}
}
if (!class_exists('WP_Error')) {
class WP_Error {
public function __construct(private string $code, private string $message = '', private $data = null) {}