user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail(), ); } public function test_shop_ledger_uses_store_report_current_subject_and_platform(): void { $openStore = [ 'id' => 901, 'platform' => '天猫', 'erp_store_name' => '天猫-报表测试店', 'company_name' => '历史主体', 'store_status' => '0', 'withdrawal_account' => '回款账户甲', ]; $closedStore = [ 'id' => 902, 'platform' => '京东', 'erp_store_name' => '京东-已关店', 'company_name' => '历史主体', 'store_status' => '6', 'withdrawal_account' => null, ]; $openStoreWithoutSubject = [ 'id' => 903, 'platform' => '淘宝', 'erp_store_name' => '淘宝-无主体店', 'company_name' => null, 'store_status' => '0', 'withdrawal_account' => null, ]; $this->mock(BusinessInformationMirrorRepository::class) ->shouldReceive('allStores') ->once() ->andReturn([$openStore, $closedStore, $openStoreWithoutSubject]); $this->mock(StoreReportPeriodBuilder::class) ->shouldReceive('build') ->once() ->with([$openStore, $openStoreWithoutSubject]) ->andReturn([ '天猫-报表测试店' => [ [ 'company_name' => '历史主体', 'effective_at' => '2026-07-01', 'expires_at' => '2026-10-01', 'source' => 'initial', ], [ 'company_name' => '当前存续主体', 'effective_at' => '2026-10-02', 'expires_at' => null, 'source' => 'crawl', ], ], ]); $this->loginAs()->get($this->pageUrl()) ->assertOk() ->assertSeeText('天猫') ->assertSeeText('天猫-报表测试店') ->assertSeeText('当前存续主体') ->assertSeeText('淘宝-无主体店') ->assertSeeText('在营') ->assertSeeText('回款账户甲') ->assertDontSeeText('京东-已关店') ->assertDontSeeText('历史主体'); } private function pageUrl(): string { return route('business.pages.show', [ 'company_id' => $this->company->id, 'section' => 'financial-operations', 'page' => 'ledger', ]); } }