shouldReceive('forSource')->once()->with('js_data_middle_platform')->andReturn($query); $query->shouldReceive('select')->once()->ordered()->with( Mockery::on(static fn (string $sql): bool => str_contains($sql, 'SELECT TOP 5000') && str_contains($sql, 'jd_jzt_finance_records')), ['2026-08'], )->andReturn([['shop_name' => '测试店铺', 'amount' => 100]]); $query->shouldReceive('select')->once()->ordered()->with( Mockery::on(static fn (string $sql): bool => str_contains($sql, 'SUM(CASE WHEN in_out_type') && str_contains($sql, 'jd_jzt_finance_records')), ['2026-08'], )->andReturn([['income' => 100, 'expense' => 0, 'record_count' => 1]]); $result = (new PlatformPromotionAccountRepository($factory))->dashboard([ 'month' => '2026-08', 'shop_name' => '', 'account' => '', ], 5000, 'jd'); $this->assertCount(1, $result['jd']); $this->assertSame(1, $result['jdSummary']['record_count']); $this->assertSame([], $result['dy']); $this->assertSame([], $result['dw']); $this->assertSame([], $result['vipSales']); } public function test_dashboard_rejects_an_unknown_platform_before_connecting(): void { $factory = Mockery::mock(UpstreamReadOnlyQueryFactory::class); $this->expectException(InvalidArgumentException::class); (new PlatformPromotionAccountRepository($factory))->dashboard([ 'month' => '2026-08', ], 200, 'unknown'); } }