CaiWuXiTong/tests/Feature/Business/FinanceLedgerShopDirectoryTest.php
92451 996e4aed69 接入店铺维度报表店铺主体数据 (#636)
Co-authored-by: 92451 <924518135@qq.com>
Co-committed-by: 92451 <924518135@qq.com>
2026-10-26 19:31:45 +08:00

72 lines
2.2 KiB
PHP

<?php
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository;
use Modules\EcommerceFinance\Services\StoreReportPeriodBuilder;
use Tests\Feature\FeatureTestCase;
class FinanceLedgerShopDirectoryTest extends FeatureTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->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,
];
$this->mock(BusinessInformationMirrorRepository::class)
->shouldReceive('allStores')
->once()
->andReturn([$openStore, $closedStore]);
$this->mock(StoreReportPeriodBuilder::class)
->shouldReceive('currentCompanies')
->once()
->with([$openStore])
->andReturn(['天猫-报表测试店' => '当前存续主体']);
$this->loginAs()->get($this->pageUrl())
->assertOk()
->assertSeeTextInOrder([
'天猫',
'天猫-报表测试店',
'当前存续主体',
'在营',
'回款账户甲',
])
->assertDontSeeText('京东-已关店')
->assertDontSeeText('历史主体');
}
private function pageUrl(): string
{
return route('business.pages.show', [
'company_id' => $this->company->id,
'section' => 'financial-operations',
'page' => 'ledger',
]);
}
}