|
|
@@ -185,6 +185,35 @@ class RechargeBonusTest extends TestCase
|
|
|
$this->assertSame('73.50', $this->balance());
|
|
|
}
|
|
|
|
|
|
+ public function test_wallet_channel_currency_filter_preserves_membership_visibility_and_bonus_fields(): void
|
|
|
+ {
|
|
|
+ DB::table('recharge_channel')->insert(['data_type' => 1, 'type' => 'szrmb', 'name' => '数字人民币']);
|
|
|
+ DB::table('payment_providers')->insert(['id' => 2, 'code' => 'sanjin', 'status' => 1]);
|
|
|
+ DB::table('recharge_channel_group')->where('id', 1)->update(['recharge_type' => 'JDpay,rgcz,usdt,szrmb']);
|
|
|
+ $fetch = function (array $params): array {
|
|
|
+ $request = Request::create('/api/wallet/channel', 'GET', $params); $request->headers->set('lang', 'en');
|
|
|
+ $request->user = \App\Models\User::find(1); $this->app->instance('request', $request);
|
|
|
+ return (new \App\Http\Controllers\api\Wallet())->getChannel()->getData(true);
|
|
|
+ };
|
|
|
+ foreach ([[], ['currency_type' => null], ['currency_type' => '']] as $params) {
|
|
|
+ $body = $fetch($params); $this->assertSame(0, $body['code']); $this->assertCount(4, $body['data']['list']);
|
|
|
+ }
|
|
|
+ $crypto = $fetch(['currency_type' => 'crypto']);
|
|
|
+ $this->assertSame(['usdt'], array_column($crypto['data']['list'], 'value'));
|
|
|
+ $this->assertSame('5', $crypto['data']['list'][0]['bonus_percent']);
|
|
|
+ $this->assertSame('Extra bonus', $crypto['data']['list'][0]['badge_text']);
|
|
|
+ $this->assertArrayHasKey('logo', $crypto['data']['list'][0]);
|
|
|
+ $fiat = $fetch(['currency_type' => 'fiat']);
|
|
|
+ $this->assertSame(['JDpay', 'rgcz', 'szrmb'], array_column($fiat['data']['list'], 'value'));
|
|
|
+ $this->assertSame([0,1,2], array_keys($fiat['data']['list']));
|
|
|
+ DB::table('recharge_channel_group')->where('id', 1)->update(['recharge_type' => 'JDpay']);
|
|
|
+ $this->assertSame([], $fetch(['currency_type' => 'crypto'])['data']['list']);
|
|
|
+ DB::table('recharge_channel_group')->where('id', 1)->update(['recharge_type' => 'usdt']);
|
|
|
+ DB::table('recharge_channel')->where('type', 'usdt')->update(['status' => 0]);
|
|
|
+ $this->assertSame([], $fetch(['currency_type' => 'crypto'])['data']['list']);
|
|
|
+ foreach (['invalid', 'all', ['crypto']] as $value) $this->assertSame(-3, $fetch(['currency_type' => $value])['code']);
|
|
|
+ }
|
|
|
+
|
|
|
public function test_actual_wallet_channel_response_localizes_bonus_and_retains_original_channel_settings(): void
|
|
|
{
|
|
|
$request = Request::create('/api/wallet/channel', 'GET'); $request->headers->set('lang', 'en');
|