CaiWuXiTong/tests/Feature/Console/SyncDingProcessDetailMirrorTest.php

76 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Tests\Feature\Console;
use Mockery;
use Modules\EcommerceFinance\Services\DingProcessDetailMirrorSynchronizer;
use Tests\Feature\FeatureTestCase;
class SyncDingProcessDetailMirrorTest extends FeatureTestCase
{
public function test_business_id_option_runs_targeted_dry_run(): void
{
$synchronizer = Mockery::mock(DingProcessDetailMirrorSynchronizer::class);
$synchronizer->shouldReceive('syncBusinessIds')
->once()
->with(
['202610151743000310225', '202610151743000310226'],
true,
true,
)
->andReturn([
'status' => 'validated',
'run_mode' => 'business_ids',
'workflows' => 1,
'details' => 2,
'payments' => 1,
'amount_total' => 15535.37,
'bank_amount_total' => 15535.37,
]);
$this->app->instance(DingProcessDetailMirrorSynchronizer::class, $synchronizer);
$this->artisan('business-mirror:sync-ding-process-details', [
'--business-id' => '202610151743000310225,202610151743000310226',
'--dry-run' => true,
])
->expectsOutputToContain('校验通过:1 个审批,2 条明细,1 笔付款')
->assertSuccessful();
}
public function test_business_id_option_can_skip_approval_api(): void
{
$synchronizer = Mockery::mock(DingProcessDetailMirrorSynchronizer::class);
$synchronizer->shouldReceive('syncBusinessIds')
->once()
->with(['202610151743000310225'], false, false)
->andReturn([
'status' => 'succeeded',
'run_mode' => 'business_ids',
'workflows' => 1,
'details' => 1,
'payments' => 1,
'amount_total' => 100.0,
'bank_amount_total' => 100.0,
]);
$this->app->instance(DingProcessDetailMirrorSynchronizer::class, $synchronizer);
$this->artisan('business-mirror:sync-ding-process-details', [
'--business-id' => '202610151743000310225',
'--skip-approval-api' => true,
])->assertSuccessful();
}
public function test_full_and_business_id_cannot_be_combined(): void
{
$synchronizer = Mockery::mock(DingProcessDetailMirrorSynchronizer::class);
$synchronizer->shouldNotReceive('sync');
$synchronizer->shouldNotReceive('syncBusinessIds');
$this->app->instance(DingProcessDetailMirrorSynchronizer::class, $synchronizer);
$this->artisan('business-mirror:sync-ding-process-details', [
'--full' => true,
'--business-id' => '202610151743000310225',
])->assertFailed();
}
}