diff --git a/tests/Unit/EcommerceFinance/ShippingReplicaSynchronizerTest.php b/tests/Unit/EcommerceFinance/ShippingReplicaSynchronizerTest.php new file mode 100644 index 00000000..b55584e2 --- /dev/null +++ b/tests/Unit/EcommerceFinance/ShippingReplicaSynchronizerTest.php @@ -0,0 +1,39 @@ +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(), + ); + } +}