53 lines
2.1 KiB
PHP
53 lines
2.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\LingxingErp\Test\Unit\Model\Shipment;
|
|
|
|
use Esun\LingxingErp\Model\Api\Client;
|
|
use Esun\LingxingErp\Model\Config;
|
|
use Esun\LingxingErp\Model\Shipment\FulfillmentNormalizer;
|
|
use Esun\LingxingErp\Model\Shipment\ShipmentPuller;
|
|
use Esun\LingxingErp\Model\Sync\LogWriter;
|
|
use Esun\LingxingErp\Model\Sync\OrderSyncRepository;
|
|
use Esun\LingxingErp\Model\Sync\ShipmentSyncRepository;
|
|
use Magento\Framework\FlagManager;
|
|
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ShipmentPullerTest extends TestCase
|
|
{
|
|
public function testLimitsRemoteRequestToTrackablePlatformOrderNumbers(): void
|
|
{
|
|
$config = $this->createMock(Config::class);
|
|
$config->method('getShipmentPageSize')->willReturn(200);
|
|
$config->method('getShipmentMaxPages')->willReturn(1);
|
|
$orderSyncRepository = $this->createMock(OrderSyncRepository::class);
|
|
$orderSyncRepository->method('getTrackablePlatformOrderNos')->willReturn(['100000001', '100000002']);
|
|
|
|
$client = $this->createMock(Client::class);
|
|
$client->expects(self::once())->method('post')->with(
|
|
'/erp/sc/routing/wms/order/wmsOrderList',
|
|
self::callback(static fn(array $request): bool =>
|
|
$request['platform_order_no_arr'] === ['100000001', '100000002']
|
|
&& !isset($request['sid_arr']))
|
|
)->willReturn(['code' => 0, 'data' => [], 'request_id' => 'request-id']);
|
|
|
|
$timezone = $this->createMock(TimezoneInterface::class);
|
|
$timezone->method('date')->willReturn(new \DateTime('2026-08-26 12:00:00'));
|
|
$flagManager = $this->createMock(FlagManager::class);
|
|
$flagManager->method('getFlagData')->willReturn(null);
|
|
|
|
$puller = new ShipmentPuller(
|
|
$client,
|
|
$config,
|
|
$timezone,
|
|
$flagManager,
|
|
$this->createMock(FulfillmentNormalizer::class),
|
|
$orderSyncRepository,
|
|
$this->createMock(ShipmentSyncRepository::class),
|
|
$this->createMock(LogWriter::class)
|
|
);
|
|
$puller->pull();
|
|
}
|
|
}
|