|
|
@@ -67,6 +67,7 @@ class PaymentChannelOptionsTest extends TestCase
|
|
|
(require dirname(__DIR__, 2) . '/database/migrations/2026_09_08_160000_add_payment_provider_status_and_channel_soft_deletes.php')->up();
|
|
|
(require dirname(__DIR__, 2) . '/database/migrations/2026_09_08_170000_add_soft_deletes_to_recharge_channel_groups.php')->up();
|
|
|
(require dirname(__DIR__, 2) . '/database/migrations/2026_10_28_150000_add_recharge_channel_logo.php')->up();
|
|
|
+ (require dirname(__DIR__, 2) . '/database/migrations/2026_10_28_160000_create_recharge_method_logos.php')->up();
|
|
|
$db->schema()->create('operation_audits', function (Blueprint $t) {
|
|
|
$t->id(); $t->string('resource_type'); $t->unsignedBigInteger('resource_id')->nullable();
|
|
|
$t->string('action'); $t->json('changes'); $t->unsignedBigInteger('operator_id')->nullable();
|
|
|
@@ -94,6 +95,57 @@ class PaymentChannelOptionsTest extends TestCase
|
|
|
return $response['data'];
|
|
|
}
|
|
|
|
|
|
+ public function test_logo_options_include_every_payment_method_even_without_enabled_or_existing_channels(): void
|
|
|
+ {
|
|
|
+ $this->request('/admin/rechargeChannel/saveLogo', []);
|
|
|
+ $service = new \App\Services\Payment\RechargeChannelLogoService();
|
|
|
+ DB::table('recharge_channel')->where('data_type', 1)->update(['status' => 0]);
|
|
|
+ DB::table('payment_providers')->update(['status' => 0]);
|
|
|
+ $options = $service->options();
|
|
|
+ $this->assertSame(13, $options['total']);
|
|
|
+ $rows = array_column($options['data'], null, 'channel_type');
|
|
|
+ foreach (['wxsm','ylsm','szrmb','zfbsm','zfbge','zfbzk','sdjt','JDpay','NOpay12','NOpay13','ZIMUpay','usdt','rgcz'] as $type) {
|
|
|
+ $this->assertArrayHasKey($type, $rows);
|
|
|
+ }
|
|
|
+ $this->assertSame('三斤支付 / 微信扫码', $rows['wxsm']['channel_name']);
|
|
|
+ DB::table('recharge_channel')->delete(); DB::table('recharge_channel_group')->delete();
|
|
|
+ $this->assertSame(13, $service->options()['total']);
|
|
|
+ $result = $service->save(['channel_type' => 'wxsm', 'logo' => 'https://cdn.example.test/wx.png']);
|
|
|
+ $this->assertSame('https://cdn.example.test/wx.png', $result['logo']);
|
|
|
+ $this->assertSame(0, DB::table('recharge_channel')->count());
|
|
|
+ $this->assertSame('https://cdn.example.test/wx.png', array_column($service->options()['data'], null, 'channel_type')['wxsm']['logo']);
|
|
|
+ $this->assertSame('', $service->save(['channel_type' => 'wxsm', 'logo' => null])['logo']);
|
|
|
+ $this->request('/admin/rechargeChannel/logoOptions', []);
|
|
|
+ $this->assertSame(13, (new RechargeChannel())->logoOptions($service)->getData(true)['data']['total']);
|
|
|
+ $router = new \Illuminate\Routing\Router(new \Illuminate\Events\Dispatcher($this->app), $this->app);
|
|
|
+ $this->app->instance('router', $router);
|
|
|
+ $router->group(['prefix' => 'admin'], function () { require dirname(__DIR__, 2) . '/routes/admin.php'; });
|
|
|
+ foreach (['logoOptions' => ['GET', 'admin/rechargeChannel/list'], 'saveLogo' => ['POST', 'admin/rechargeChannel/update']] as $path => [$method, $permission]) {
|
|
|
+ $route = $router->getRoutes()->match(Request::create('/admin/rechargeChannel/' . $path, $method));
|
|
|
+ $this->assertSame($permission, $route->defaults['permission_uri']);
|
|
|
+ $this->assertContains('admin.jwt', $route->middleware()); $this->assertContains('check.button.uri', $route->middleware());
|
|
|
+ }
|
|
|
+
|
|
|
+ try { $service->save(['channel_type' => 'DF001', 'logo' => '/a.png']); $this->fail('Withdrawal-only method accepted'); }
|
|
|
+ catch (\Illuminate\Validation\ValidationException $e) { $this->assertArrayHasKey('channel_type', $e->errors()); }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test_logo_preconfiguration_is_inherited_by_later_channels_and_migration_retains_old_uploads(): void
|
|
|
+ {
|
|
|
+ $this->request('/admin/rechargeChannel/saveLogo', []);
|
|
|
+ $migration = require dirname(__DIR__, 2) . '/database/migrations/2026_10_28_160000_create_recharge_method_logos.php';
|
|
|
+ $migration->down();
|
|
|
+ DB::table('recharge_channel')->where('id', 2)->update(['logo' => '/storage/wx.png']);
|
|
|
+ $migration->up();
|
|
|
+ $this->assertSame('/storage/wx.png', DB::table('recharge_method_logos')->where('channel_type', 'wxsm')->value('logo'));
|
|
|
+ DB::table('recharge_channel')->where('type', 'JDpay')->where('data_type', 1)->delete();
|
|
|
+ $service = new \App\Services\Payment\RechargeChannelLogoService();
|
|
|
+ $service->save(['channel_type' => 'JDpay', 'logo' => 'https://cdn.example.test/jd.png']);
|
|
|
+ $body = $this->saveChannel($this->newChannel(['payment_company' => 'jd', 'type' => 'JDpay']));
|
|
|
+ $this->assertSame(0, $body['code'], $body['msg']);
|
|
|
+ $this->assertSame('https://cdn.example.test/jd.png', \App\Models\RechargeChannel::where('data_type', 1)->where('type', 'JDpay')->first()->logo);
|
|
|
+ }
|
|
|
+
|
|
|
public function test_deposit_logos_upload_save_share_by_method_and_can_be_cleared(): void
|
|
|
{
|
|
|
$this->app['config']->set('app.url', 'https://admin.example.test');
|