40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\EcommerceFinance;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Modules\EcommerceFinance\Services\Jushuitan\ShippingReplicaSynchronizer;
|
|
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
|
|
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
|
|
use Tests\TestCase;
|
|
|
|
class ShippingReplicaSynchronizerTest extends TestCase
|
|
{
|
|
public function test_sync_removes_only_the_known_demo_source_ids(): void
|
|
{
|
|
$db = DB::connection('business_mirror');
|
|
$db->table('jst_oms_shipping')->insert([
|
|
['source_id' => 9000001, 'sku_source_id' => 9000001],
|
|
['source_id' => 9000006, 'sku_source_id' => 9000006],
|
|
['source_id' => 9000007, 'sku_source_id' => 9000007],
|
|
['source_id' => 999999999, 'sku_source_id' => 999999999],
|
|
]);
|
|
|
|
$upstream = $this->createMock(UpstreamReadOnlyQuery::class);
|
|
$upstream->expects($this->once())->method('select')->willReturn([]);
|
|
$factory = $this->createMock(UpstreamReadOnlyQueryFactory::class);
|
|
$factory->expects($this->once())
|
|
->method('forSource')
|
|
->with('operations_replica')
|
|
->willReturn($upstream);
|
|
|
|
$result = (new ShippingReplicaSynchronizer($factory))->sync();
|
|
|
|
$this->assertSame(['processed' => 0, 'autoship' => 0], $result);
|
|
$this->assertSame(
|
|
[9000007, 999999999],
|
|
$db->table('jst_oms_shipping')->orderBy('source_id')->pluck('source_id')->map(fn ($id) => (int) $id)->all(),
|
|
);
|
|
}
|
|
}
|