shouldReceive('latestMonth')->once()->andReturn('2026-08'); $repository->shouldReceive('dashboard')->once()->with([ 'month' => '2026-08', 'shop_name' => '', 'account' => '', ], 5000)->andReturn($this->dashboardData()); $this->app->instance(PlatformPromotionAccountRepository::class, $repository); $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'billing-transactions', 'page' => 'platform-promotion-accounts', 'tab' => 'jd', ])) ->assertOk() ->assertSeeText('平台推广账户流水') ->assertSeeText('京东京准通') ->assertSeeText('测试店铺') ->assertSeeText('导出 CSV') ->assertSee(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'bill-offset', ]), false); } public function test_platform_promotion_export_keeps_the_complete_filtered_month(): void { $repository = Mockery::mock(PlatformPromotionAccountRepository::class); $repository->shouldReceive('latestMonth')->never(); $repository->shouldReceive('dashboard')->once()->with([ 'month' => '2026-08', 'shop_name' => '测试', 'account' => 'account-01', ], 5000)->andReturn($this->dashboardData()); $this->app->instance(PlatformPromotionAccountRepository::class, $repository); $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $response = $this->loginAs()->get(route('business.pages.export', [ 'section' => 'billing-transactions', 'page' => 'platform-promotion-accounts', 'tab' => 'jd', 'month' => '2026-08', 'shop_name' => '测试', 'account' => 'account-01', ])); $response->assertOk(); $response->assertHeader('Content-Type', 'text/csv; charset=UTF-8'); $disposition = (string) $response->headers->get('Content-Disposition'); $this->assertStringContainsString("filename*=utf-8''", $disposition); $this->assertStringContainsString('2026-08.csv', $disposition); $this->assertStringContainsString('测试店铺', $response->streamedContent()); } private function dashboardData(): array { return [ 'jd' => [[ 'shop_name' => '测试店铺', 'account' => 'account-01', 'show_date' => '2026-08-01', 'trade_type_name' => '充值', 'amount' => 100, 'balance_amount' => 100, 'remark' => '测试记录', ]], 'jdSummary' => ['income' => 100, 'expense' => 0, 'record_count' => 1], 'dy' => [], 'dySummary' => [], 'dyStatus' => [], 'dw' => [], 'dwSummary' => [], 'vipSales' => [], 'vipTax' => [], 'vipMarketing' => [], 'vipSummary' => [], ]; } }