48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\EcommerceFinance;
|
|
|
|
use Mockery;
|
|
use Modules\EcommerceFinance\Services\AccountMappingCoverage;
|
|
use Tests\TestCase;
|
|
|
|
class RefreshAccountMappingCoverageCommandTest extends TestCase
|
|
{
|
|
public function test_monthly_mode_skips_when_the_current_month_snapshot_exists(): void
|
|
{
|
|
$coverage = Mockery::mock(AccountMappingCoverage::class);
|
|
$coverage->shouldReceive('monthlyRefreshDue')->once()->andReturn(false);
|
|
$coverage->shouldNotReceive('refreshAllMonths');
|
|
$this->app->instance(AccountMappingCoverage::class, $coverage);
|
|
|
|
$this->artisan('account-mapping:refresh-coverage', ['--monthly' => true])
|
|
->expectsOutput('本月未映射清单已生成,无需重复刷新。')
|
|
->assertExitCode(0);
|
|
}
|
|
|
|
public function test_monthly_mode_refreshes_once_when_the_month_is_due(): void
|
|
{
|
|
$coverage = Mockery::mock(AccountMappingCoverage::class);
|
|
$coverage->shouldReceive('monthlyRefreshDue')->once()->andReturn(true);
|
|
$coverage->shouldReceive('refreshAllMonths')->once()->andReturn([
|
|
'status' => 'ready',
|
|
'source_rows' => 10,
|
|
'pending_sources' => [],
|
|
'pairs' => [],
|
|
]);
|
|
$coverage->shouldReceive('missingAcrossMonths')->once()->andReturn([
|
|
'status' => 'ready',
|
|
'month' => null,
|
|
'source_rows' => 10,
|
|
'missing_item_count' => 2,
|
|
'missing_row_count' => 3,
|
|
'pending_sources' => [],
|
|
'items' => [],
|
|
]);
|
|
$this->app->instance(AccountMappingCoverage::class, $coverage);
|
|
|
|
$this->artisan('account-mapping:refresh-coverage', ['--monthly' => true])
|
|
->assertExitCode(0);
|
|
}
|
|
}
|