shouldReceive('paginateAccountBills') ->once() ->with( ['start' => '2026-11-30', 'end' => '2026-11-30'], 'occurred_at', 'desc', 1, 1, ) ->andReturn([ 'total' => 766, 'summary' => ['income' => 28878.98, 'expense' => 2149.18], ]); $this->app->instance(TaobaoWechatSettlementBillRepository::class, $wechat); $jd = Mockery::mock(JdDailyBillRepository::class); foreach (['jd' => [32, 1460.76, 73.58], 'jingxi' => [5, 100.00, 20.00]] as $platform => $values) { $jd->shouldReceive('forPlatform') ->once() ->with($platform) ->andReturnSelf(); $jd->shouldReceive('paginate') ->once() ->with( ['start' => '2026-11-30', 'end' => '2026-11-30'], 'occurred_at', 'desc', 1, 1, ) ->andReturn([ 'total' => $values[0], 'summary' => ['income' => $values[1], 'expense' => $values[2]], ]); } $this->app->instance(JdDailyBillRepository::class, $jd); $exitCode = Artisan::call('bill-sync:summarize-range', [ '--tabs' => 'taobao-wechat,jd-transactions,jingxi', '--from' => '2026-11-30', '--to' => '2026-11-30', '--company-id' => 1, '--json' => true, ]); $this->assertSame(0, $exitCode); $result = json_decode(Artisan::output(), true, 512, JSON_THROW_ON_ERROR); $this->assertSame(803, $result['row_count']); $this->assertSame(3043974, $result['income_cents']); $this->assertSame(224276, $result['expense_cents']); $this->assertSame(766, $result['platforms']['taobao-wechat']['row_count']); $this->assertSame(32, $result['platforms']['jd-transactions']['row_count']); $this->assertSame(5, $result['platforms']['jingxi']['row_count']); } public function test_it_rejects_unknown_tabs(): void { $exitCode = Artisan::call('bill-sync:summarize-range', [ '--tabs' => 'unknown', '--from' => '2026-11-30', '--to' => '2026-11-30', '--json' => true, ]); $this->assertSame(1, $exitCode); $this->assertStringContainsString('账单页签无效', Artisan::output()); } }