CaiWuXiTong/tests/Unit/EcommerceFinance/StoreReportCurrentCompanyTest.php
92451 03acb8b1a0 fix: 提现管理按店铺报表取存续主体
提现管理主体跟随店铺维度报表最新存续期间。

PR #559
Co-authored-by: 92451 <924518135@qq.com>
Co-committed-by: 92451 <924518135@qq.com>
2026-10-25 20:36:57 +08:00

36 lines
1.4 KiB
PHP

<?php
namespace Tests\Unit\EcommerceFinance;
use Mockery;
use Modules\EcommerceFinance\Services\StoreReportPeriodBuilder;
use Tests\TestCase;
class StoreReportCurrentCompanyTest extends TestCase
{
public function test_it_selects_the_latest_non_expiring_period_company(): void
{
$stores = [
['erp_store_name' => '店铺A'],
['erp_store_name' => '店铺B'],
['erp_store_name' => '店铺C'],
];
$periods = Mockery::mock(StoreReportPeriodBuilder::class)->makePartial();
$periods->shouldReceive('build')->once()->with($stores)->andReturn([
'店铺A' => [
['company_name' => '旧主体', 'effective_at' => '2026-07-01', 'expires_at' => '2026-09-13'],
['company_name' => '过渡主体', 'effective_at' => '2026-09-14', 'expires_at' => null],
['company_name' => '最新主体', 'effective_at' => '2026-10-01', 'expires_at' => null],
],
'店铺B' => [
['company_name' => '已失效主体', 'effective_at' => '2026-07-01', 'expires_at' => '2026-09-30'],
],
'店铺C' => [
['company_name' => null, 'effective_at' => '2026-07-01', 'expires_at' => null],
],
]);
$this->assertSame(['店铺A' => '最新主体'], $periods->currentCompanies($stores));
}
}