AgentApiRegressionTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <?php
  2. namespace Tests\Integration;
  3. use App\Http\Controllers\admin\Agent as AdminAgent;
  4. use App\Http\Controllers\AgentApiController;
  5. use App\Http\Middleware\AgentAuthMiddleware;
  6. use App\Models\Agent\Agent;
  7. use App\Models\Agent\AgentBalanceLog;
  8. use App\Models\Agent\AgentDailyGameStat;
  9. use App\Models\Agent\AgentFlowCommissionProfile;
  10. use App\Models\Agent\AgentLoginLog;
  11. use App\Models\Agent\AgentRebateRecord;
  12. use App\Models\Agent\AgentToken;
  13. use App\Models\Agent\AgentWithdrawAccount;
  14. use App\Models\Agent\AgentWithdrawal;
  15. use App\Services\Agent\AgentCommissionService;
  16. use App\Services\Agent\AgentFlowCommissionAssignmentService;
  17. use App\Services\Agent\AgentMemberService;
  18. use App\Services\Agent\AgentProfitCommissionAssignmentService;
  19. use App\Services\Agent\AgentReportService;
  20. use App\Services\Agent\AgentService;
  21. use App\Services\Agent\AgentWalletService;
  22. use App\Services\Agent\AgentWithdrawalService;
  23. use App\Services\PaymentOrderService;
  24. use Carbon\Carbon;
  25. use Illuminate\Config\Repository;
  26. use Illuminate\Contracts\Debug\ExceptionHandler;
  27. use Illuminate\Database\Capsule\Manager;
  28. use Illuminate\Database\QueryException;
  29. use Illuminate\Database\Schema\Blueprint;
  30. use Illuminate\Events\Dispatcher;
  31. use Illuminate\Foundation\Application;
  32. use Illuminate\Hashing\BcryptHasher;
  33. use Illuminate\Http\JsonResponse;
  34. use Illuminate\Http\Request;
  35. use Illuminate\Support\Facades\DB;
  36. use Illuminate\Support\Facades\Facade;
  37. use Illuminate\Support\Facades\Schema;
  38. use Illuminate\Translation\ArrayLoader;
  39. use Illuminate\Translation\Translator;
  40. use Illuminate\Validation\Factory;
  41. use PHPUnit\Framework\TestCase;
  42. class AgentApiRegressionTest extends TestCase
  43. {
  44. private Application $app;
  45. private AgentService $agents;
  46. protected function setUp(): void
  47. {
  48. parent::setUp();
  49. Carbon::setTestNow(Carbon::parse('2026-09-07 12:00:00'));
  50. Facade::clearResolvedInstances();
  51. $this->app = new Application(dirname(__DIR__, 2));
  52. $this->app->instance('config', new Repository(['app' => ['locale' => 'zh'], 'agent' => []]));
  53. Facade::setFacadeApplication($this->app);
  54. $db = new Manager($this->app);
  55. $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => 'bot_']);
  56. $db->setEventDispatcher(new Dispatcher($this->app));
  57. $db->setAsGlobal();
  58. $db->bootEloquent();
  59. $this->app->instance('db', $db->getDatabaseManager());
  60. $this->app->bind('db.schema', fn () => $db->schema());
  61. $this->app->instance('hash', new BcryptHasher(['rounds' => 4]));
  62. $translator = new Translator(new ArrayLoader(), 'zh');
  63. $this->app->instance('translator', $translator);
  64. $this->app->instance('validator', new Factory($translator, $this->app));
  65. $this->app->instance('request', Request::create('/'));
  66. Request::macro('validate', function (array $rules) {
  67. return app('validator')->make($this->all(), $rules)->validate();
  68. });
  69. $responses = new class {
  70. public function json($data, $status = 200, $headers = [], $options = 0) {
  71. return new JsonResponse($data, $status, $headers, $options);
  72. }
  73. };
  74. $this->app->instance(\Illuminate\Contracts\Routing\ResponseFactory::class, $responses);
  75. Schema::create('users', function (Blueprint $t) {
  76. $t->id(); $t->string('member_id'); $t->string('username'); $t->string('first_name')->default('');
  77. $t->integer('status')->default(1); $t->string('register_ip')->default('');
  78. $t->string('register_domain')->default(''); $t->timestamps();
  79. });
  80. foreach (['2026_08_24_140000_create_agent_system_tables.php',
  81. '2026_08_28_120000_create_agent_profit_profiles_and_rebate_records.php'] as $file) {
  82. (require dirname(__DIR__, 2) . '/database/migrations/' . $file)->up();
  83. }
  84. // Flow migration repairs MySQL information_schema indexes; use equivalent SQLite test tables.
  85. Schema::create('agent_flow_commission_profiles', function (Blueprint $t) {
  86. $t->id(); $t->string('name'); $t->integer('is_default')->default(0); $t->timestamps();
  87. foreach (AgentFlowCommissionProfile::RATE_FIELDS as $field) $t->decimal($field, 8, 4)->default(0);
  88. });
  89. Schema::create('agent_flow_commission_assignments', function (Blueprint $t) {
  90. $t->id(); $t->unsignedBigInteger('agent_id'); $t->unsignedBigInteger('flow_commission_profile_id');
  91. $t->string('profile_name'); $t->date('effective_from'); $t->unsignedBigInteger('created_by')->nullable();
  92. foreach (AgentFlowCommissionProfile::RATE_FIELDS as $field) $t->decimal($field, 8, 4)->default(0);
  93. $t->timestamps(); $t->unique(['agent_id', 'effective_from']);
  94. });
  95. Schema::table('agents', fn (Blueprint $t) => $t->unsignedBigInteger('flow_commission_profile_id')->nullable());
  96. DB::table('agent_flow_commission_profiles')->insert(['name' => 'Default', 'is_default' => 1]);
  97. foreach (['agent_flow_commission_profiles', 'agent_profit_commission_profiles'] as $table) {
  98. Schema::table($table, fn (Blueprint $t) => $t->unsignedBigInteger('owner_agent_id')->nullable());
  99. }
  100. foreach (['recharges', 'withdraws', 'payment_orders'] as $table) {
  101. Schema::create($table, function (Blueprint $t) {
  102. $t->id(); $t->string('member_id'); $t->integer('status'); $t->string('type')->nullable();
  103. $t->decimal('amount', 18, 4); $t->timestamps();
  104. });
  105. }
  106. Schema::create('wallets', function (Blueprint $t) {
  107. $t->id(); $t->string('member_id'); $t->decimal('available_balance', 18, 4)->default(0);
  108. $t->decimal('frozen_balance', 18, 4)->default(0);
  109. });
  110. Schema::create('balance_logs', function (Blueprint $t) {
  111. $t->id(); $t->string('member_id'); $t->string('change_type');
  112. $t->integer('related_id')->nullable(); $t->decimal('amount', 18, 4); $t->timestamps();
  113. });
  114. $this->agents = new AgentService(new AgentFlowCommissionAssignmentService(), new AgentProfitCommissionAssignmentService());
  115. }
  116. protected function tearDown(): void
  117. {
  118. DB::disconnect();
  119. Facade::clearResolvedInstances();
  120. Carbon::setTestNow();
  121. parent::tearDown();
  122. }
  123. private function agent(?Agent $parent = null): Agent
  124. {
  125. static $number = 0;
  126. return $this->agents->create([
  127. 'username' => 'agent' . ++$number, 'password' => 'old-password',
  128. 'withdraw_password' => 'withdraw-old',
  129. 'flow_commission_profile_id' => AgentFlowCommissionProfile::officialDefaultId(),
  130. ], null, $parent);
  131. }
  132. private function token(Agent $agent): string
  133. {
  134. $plain = 'test-token-' . $agent->id;
  135. AgentToken::query()->create(['agent_id' => $agent->id, 'token_hash' => hash('sha256', $plain),
  136. 'expires_at' => now()->addDay(), 'last_used_at' => now(), 'ip' => '', 'device' => 'pc']);
  137. return $plain;
  138. }
  139. public function test_admin_password_reset_revokes_old_login(): void
  140. {
  141. $agent = $this->agent(); $token = $this->token($agent);
  142. $this->agents->update($agent, ['password' => 'new-password']);
  143. $this->assertSame(0, AgentToken::query()->where('agent_id', $agent->id)->count());
  144. $request = Request::create('/agent/profile');
  145. $request->headers->set('Authorization', 'Bearer ' . $token);
  146. $response = (new AgentAuthMiddleware())->handle($request, fn () => new JsonResponse(['code' => 0]));
  147. $this->assertSame(101011, $response->getData(true)['code']);
  148. }
  149. public function test_disable_then_enable_does_not_restore_old_login(): void
  150. {
  151. $agent = $this->agent(); $this->token($agent);
  152. $this->agents->update($agent, ['status' => 0]);
  153. $this->agents->update($agent, ['status' => 1]);
  154. $this->assertSame(0, AgentToken::query()->count());
  155. }
  156. public function test_non_sensitive_edit_preserves_login(): void
  157. {
  158. $agent = $this->agent(); $this->token($agent);
  159. $this->agents->update($agent, ['real_name' => 'new name']);
  160. $this->assertSame(1, AgentToken::query()->count());
  161. }
  162. public function test_finance_counts_include_only_successful_in_range_provider_orders(): void
  163. {
  164. $agent = $this->agent();
  165. DB::table('users')->insert(['member_id' => 'm1', 'username' => 'member', 'agent_id' => $agent->id,
  166. 'created_at' => '2026-01-01 00:00:00']);
  167. $base = ['member_id' => 'm1', 'amount' => 10, 'created_at' => now()];
  168. DB::table('recharges')->insert($base + ['status' => 1]);
  169. DB::table('withdraws')->insert($base + ['status' => 1]);
  170. foreach ([PaymentOrderService::TYPE_PAY, PaymentOrderService::TYPE_PAYOUT, PaymentOrderService::TYPE_SELF_PAYOUT] as $type) {
  171. DB::table('payment_orders')->insert($base + ['type' => $type, 'status' => PaymentOrderService::STATUS_SUCCESS]);
  172. }
  173. DB::table('payment_orders')->insert($base + ['type' => PaymentOrderService::TYPE_PAY, 'status' => -99]);
  174. DB::table('payment_orders')->insert(array_merge($base, ['type' => PaymentOrderService::TYPE_PAY,
  175. 'status' => PaymentOrderService::STATUS_SUCCESS, 'created_at' => '2026-08-01 00:00:00']));
  176. DB::table('payment_orders')->insert(array_merge($base, ['type' => PaymentOrderService::TYPE_PAY,
  177. 'status' => PaymentOrderService::STATUS_SUCCESS, 'member_id' => 'unrelated']));
  178. $result = (new AgentMemberService(new AgentReportService()))->finance($agent, []);
  179. $member = $result['list'][0];
  180. $this->assertSame(2, $member->recharge_count);
  181. $this->assertSame(3, $member->withdraw_count);
  182. $this->assertSame('20.0000', $member->recharge_amount);
  183. $this->assertSame('30.0000', $member->withdraw_amount);
  184. }
  185. public function test_login_logs_filter_login_time_not_record_creation_time(): void
  186. {
  187. $agent = $this->agent();
  188. AgentLoginLog::query()->create(['agent_id' => $agent->id, 'username' => $agent->username,
  189. 'login_at' => '2026-09-06 23:59:59', 'created_at' => '2026-09-07 00:00:01']);
  190. $controller = new AdminAgent();
  191. $request = Request::create('/admin/agent/login-logs', 'GET', ['start_date' => '2026-09-06', 'end_date' => '2026-09-06']);
  192. $this->assertSame(1, $controller->loginLogs($request)->getData(true)['data']['total']);
  193. }
  194. private function fundedAccount(Agent $agent): AgentWithdrawAccount
  195. {
  196. Agent::query()->whereKey($agent->id)->update(['balance' => 100]);
  197. return AgentWithdrawAccount::query()->create(['agent_id' => $agent->id, 'type' => 'bank', 'account' => 'test-account', 'status' => 1]);
  198. }
  199. public function test_withdrawal_uses_current_password_not_stale_request_model(): void
  200. {
  201. $agent = $this->agent(); $account = $this->fundedAccount($agent);
  202. $this->agents->update($agent, ['withdraw_password' => 'withdraw-new']);
  203. $this->expectException(\InvalidArgumentException::class);
  204. $this->expectExceptionMessage('提现密码错误');
  205. (new AgentWithdrawalService())->request($agent, $account->id, '10', 'withdraw-old', 'stale');
  206. }
  207. public function test_disabled_agent_cannot_submit_with_stale_request_model(): void
  208. {
  209. $agent = $this->agent(); $account = $this->fundedAccount($agent);
  210. $this->agents->update($agent, ['status' => 0]);
  211. $this->expectException(\RuntimeException::class);
  212. $this->expectExceptionMessage('代理账号已禁用');
  213. (new AgentWithdrawalService())->request($agent, $account->id, '10', 'withdraw-old', 'disabled');
  214. }
  215. public function test_withdrawal_retry_and_rejection_move_funds_once(): void
  216. {
  217. $agent = $this->agent(); $account = $this->fundedAccount($agent);
  218. $service = new AgentWithdrawalService();
  219. $one = $service->request($agent, $account->id, '10', 'withdraw-old', 'retry');
  220. $two = $service->request($agent, $account->id, '10', 'withdraw-old', 'retry');
  221. $this->assertSame($one->id, $two->id);
  222. $this->assertSame('90.0000', $agent->fresh()->balance);
  223. $this->assertSame('10.0000', $agent->fresh()->frozen_balance);
  224. $service->audit($one->id, 'reject', 1);
  225. $this->assertSame('100.0000', $agent->fresh()->balance);
  226. $this->assertSame('0.0000', $agent->fresh()->frozen_balance);
  227. $this->assertSame(1, AgentWithdrawal::query()->count());
  228. $this->assertSame(2, AgentBalanceLog::query()->count());
  229. }
  230. public function test_transfer_rechecks_current_parent_inside_service(): void
  231. {
  232. $root = $this->agent(); $child = $this->agent($root); $other = $this->agent();
  233. Agent::query()->whereKey($root->id)->update(['balance' => 100]);
  234. Agent::query()->whereKey($child->id)->update(['parent_id' => $other->id, 'path' => $other->path . $child->id . '/']);
  235. $this->expectException(\RuntimeException::class);
  236. $this->expectExceptionMessage('只能操作当前直属下级的额度');
  237. (new AgentWalletService())->transfer($root->id, $child->id, '10', 'test', 'moved', $root->id);
  238. }
  239. public function test_transfer_retry_and_reclaim_from_disabled_child(): void
  240. {
  241. $root = $this->agent(); $child = $this->agent($root);
  242. Agent::query()->whereKey($root->id)->update(['balance' => 100]);
  243. $wallets = new AgentWalletService();
  244. $wallets->transfer($root->id, $child->id, '10', 'test', 'once', $root->id);
  245. $wallets->transfer($root->id, $child->id, '10', 'test', 'once', $root->id);
  246. $this->assertSame('90.0000', $root->fresh()->balance);
  247. $this->agents->update($child, ['status' => 0]);
  248. $wallets->transfer($child->id, $root->id, '10', 'test', 'reclaim', $root->id);
  249. $this->assertSame('100.0000', $root->fresh()->balance);
  250. $this->assertSame('0.0000', $child->fresh()->balance);
  251. }
  252. public function test_historical_settlement_ignores_new_agents_and_new_children(): void
  253. {
  254. Carbon::setTestNow(Carbon::parse('2026-09-06 12:00:00'));
  255. $root = $this->agent();
  256. Carbon::setTestNow(Carbon::parse('2026-09-07 12:00:00'));
  257. $this->agent($root); $this->agent();
  258. $service = new AgentCommissionService(new AgentReportService(), new AgentWalletService(),
  259. new AgentFlowCommissionAssignmentService(), new AgentProfitCommissionAssignmentService());
  260. $this->assertSame(['created' => 0, 'credited' => 0], $service->settle('2026-09-06', false));
  261. }
  262. public function test_daily_game_stats_work_with_bot_table_prefix(): void
  263. {
  264. $agent = $this->agent();
  265. DB::table('users')->insert(['member_id' => 'm1', 'username' => 'member', 'agent_id' => $agent->id]);
  266. Schema::create('bets', function (Blueprint $t) {
  267. $t->id(); $t->string('member_id'); $t->integer('status');
  268. $t->decimal('amount', 18, 4); $t->decimal('profit', 18, 4); $t->timestamps();
  269. });
  270. DB::table('bets')->insert(['member_id' => 'm1', 'status' => 2, 'amount' => 10, 'profit' => 0, 'created_at' => now()]);
  271. foreach (['sport_game_order', 'jisu_game_order'] as $table) {
  272. Schema::create($table, function (Blueprint $t) {
  273. $t->id(); $t->string('member_id'); $t->integer('status');
  274. $t->decimal('amount', 18, 4); $t->decimal('profit_and_loss', 18, 4); $t->timestamps();
  275. });
  276. DB::table($table)->insert(['member_id' => 'm1', 'status' => 1, 'amount' => 10, 'profit_and_loss' => 0, 'created_at' => now()]);
  277. }
  278. Schema::create('lhc_order', function (Blueprint $t) {
  279. $t->id(); $t->string('member_id'); $t->integer('lottery_status');
  280. $t->decimal('amount', 18, 4); $t->decimal('total_amount', 18, 4)->nullable();
  281. $t->decimal('win_amount', 18, 4); $t->integer('created_at');
  282. });
  283. DB::table('lhc_order')->insert(['member_id' => 'm1', 'lottery_status' => 1, 'amount' => 10,
  284. 'total_amount' => null, 'win_amount' => 0, 'created_at' => now()->timestamp]);
  285. (require dirname(__DIR__, 2) . '/database/migrations/2026_08_21_120000_create_third_game_orders_table.php')->up();
  286. DB::table('third_game_orders')->insert(['user_id' => DB::table('users')->value('id'), 'member_id' => 'm1',
  287. 'order_key' => 'test', 'game_order_id' => 'test', 'player_id' => 'test', 'currency' => 'CNY',
  288. 'platform' => 'TEST', 'game_type' => 1, 'status' => 1,
  289. 'bet_amount' => 10, 'valid_amount' => 10, 'settled_amount' => -10, 'last_update_time' => now()]);
  290. $reports = new AgentReportService();
  291. $this->assertSame(5, $reports->refreshDailyGameStats('2026-09-07'));
  292. foreach (AgentDailyGameStat::query()->get() as $stat) {
  293. $this->assertSame('10.0000', $stat->valid_bet_amount);
  294. $this->assertSame('-10.0000', $stat->win_loss);
  295. }
  296. $summary = $reports->summaryForTree($agent, '2026-09-07', '2026-09-07');
  297. $this->assertSame(5, $summary['bet_count']);
  298. $this->assertSame('50.0000', $summary['valid_bet_amount']);
  299. $this->assertSame('-50.0000', $summary['win_loss']);
  300. }
  301. public function test_member_finance_does_not_include_other_agent_tree(): void
  302. {
  303. $root = $this->agent(); $child = $this->agent($root); $other = $this->agent();
  304. foreach ([$root, $child, $other] as $agent) {
  305. DB::table('users')->insert(['member_id' => 'm' . $agent->id, 'username' => 'member' . $agent->id,
  306. 'agent_id' => $agent->id, 'created_at' => now()]);
  307. }
  308. $service = new AgentMemberService(new AgentReportService());
  309. $this->assertSame(2, $service->finance($root, [])['total']);
  310. $this->assertSame(0, $service->finance($root, ['agent_id' => $other->id])['total']);
  311. $this->assertSame(1, $service->finance($child, [])['total']);
  312. }
  313. public function test_sub_agent_cannot_take_profile_higher_than_parent(): void
  314. {
  315. $root = $this->agent();
  316. $profile = AgentFlowCommissionProfile::query()->create(['name' => 'High rate', 'live_rate' => 90]);
  317. $this->expectException(\RuntimeException::class);
  318. $this->expectExceptionMessage('下级代理流水佣金方案不能高于上级方案');
  319. $this->agents->create(['username' => 'child-high', 'password' => 'password',
  320. 'flow_commission_profile_id' => $profile->id], null, $root);
  321. }
  322. public function test_business_errors_keep_existing_response_contract(): void
  323. {
  324. $controller = new class extends AgentApiController {
  325. public function trigger() {
  326. return $this->execute(fn () => throw new \RuntimeException('代理余额不足'));
  327. }
  328. };
  329. $data = $controller->trigger()->getData(true);
  330. $this->assertSame(['code', 'timestamp', 'msg', 'data'], array_keys($data));
  331. $this->assertSame(-3, $data['code']);
  332. $this->assertSame('代理余额不足', $data['msg']);
  333. }
  334. public function test_settlement_preview_credit_and_retry_preserve_paid_snapshot(): void
  335. {
  336. Carbon::setTestNow(Carbon::parse('2026-09-06 12:00:00'));
  337. DB::table('agent_flow_commission_profiles')->update(['live_rate' => 1]);
  338. DB::table('agent_profit_commission_profiles')->update(['live_rate' => 2]);
  339. $agent = $this->agent();
  340. DB::table('agent_daily_game_stats')->insert(['stat_date' => '2026-09-06', 'agent_id' => $agent->id,
  341. 'platform' => 'test', 'game_type' => 1, 'bet_count' => 1, 'bet_amount' => 100,
  342. 'valid_bet_amount' => 100, 'win_loss' => -50]);
  343. Carbon::setTestNow(Carbon::parse('2026-09-07 12:00:00'));
  344. $service = new AgentCommissionService(new AgentReportService(), new AgentWalletService(),
  345. new AgentFlowCommissionAssignmentService(), new AgentProfitCommissionAssignmentService());
  346. $this->assertSame(['created' => 1, 'credited' => 0], $service->settle('2026-09-06', false));
  347. $this->assertSame('0.0000', $agent->fresh()->balance);
  348. $this->assertSame(['created' => 0, 'credited' => 2], $service->settle('2026-09-06'));
  349. $this->assertSame('2.0000', $agent->fresh()->balance);
  350. DB::table('agent_daily_game_stats')->update(['valid_bet_amount' => 200]);
  351. $this->assertSame(['created' => 0, 'credited' => 0], $service->settle('2026-09-06'));
  352. $this->assertSame('2.0000', $agent->fresh()->balance);
  353. $this->assertSame('100.0000', AgentRebateRecord::query()->firstOrFail()->valid_bet_amount);
  354. $this->assertSame(2, AgentBalanceLog::query()->count());
  355. }
  356. public function test_settlement_command_rejects_invalid_and_unfinished_dates(): void
  357. {
  358. $handler = $this->createMock(ExceptionHandler::class);
  359. $handler->expects($this->exactly(3))->method('report');
  360. $this->app->instance(ExceptionHandler::class, $handler);
  361. $reports = $this->createMock(AgentReportService::class);
  362. $reports->expects($this->never())->method('refreshDaily');
  363. $this->app->instance(AgentReportService::class, $reports);
  364. $commissions = $this->createMock(AgentCommissionService::class);
  365. $commissions->expects($this->never())->method('settle');
  366. $this->app->instance(AgentCommissionService::class, $commissions);
  367. foreach (['2026-02-30', '2026-09-07', '2026-09-08'] as $date) {
  368. $command = new \App\Console\Commands\AgentDailySettle();
  369. $command->setLaravel($this->app);
  370. $tester = new \Symfony\Component\Console\Tester\CommandTester($command);
  371. $this->assertSame(1, $tester->execute(['date' => $date]));
  372. }
  373. }
  374. public function test_sql_errors_are_logged_but_not_returned_to_frontend(): void
  375. {
  376. $handler = $this->createMock(ExceptionHandler::class);
  377. $handler->expects($this->once())->method('report');
  378. $this->app->instance(ExceptionHandler::class, $handler);
  379. $controller = new class extends AgentApiController {
  380. public function trigger() {
  381. return $this->execute(fn () => throw new QueryException('select sensitive_table', ['secret'], new \PDOException('internal database error')));
  382. }
  383. };
  384. $data = $controller->trigger()->getData(true);
  385. $this->assertSame(-3, $data['code']);
  386. $this->assertSame('系统处理失败,请稍后重试', $data['msg']);
  387. $this->assertSame([], $data['data']);
  388. }
  389. }