Files
2026-09-15 10:35:56 +08:00

42 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Test\Unit\Model\Warehouse;
use Esun\LingxingErp\Model\Api\Client;
use Esun\LingxingErp\Model\Api\Endpoint;
use Esun\LingxingErp\Model\Sync\LogWriter;
use Esun\LingxingErp\Model\Warehouse\WarehouseFetcher;
use PHPUnit\Framework\TestCase;
class WarehouseFetcherTest extends TestCase
{
public function testFetchesOnlyTypeThreeWarehouses(): void
{
$client = $this->createMock(Client::class);
$client->expects(self::once())
->method('post')
->willReturnCallback(function (string $path, array $request): array {
self::assertSame(Endpoint::WAREHOUSE_LIST, $path);
self::assertSame(3, $request['type']);
self::assertSame('0,1', $request['is_delete']);
return [
'code' => 0,
'data' => [[
'wid' => 200,
'name' => 'Warehouse ' . $request['type'],
'type' => $request['type'],
]],
'total' => 1,
];
});
$logWriter = $this->createMock(LogWriter::class);
$logWriter->expects(self::once())->method('write');
$result = (new WarehouseFetcher($client, $logWriter))->fetchAll();
self::assertCount(1, $result);
self::assertSame([200], array_column($result, 'wid'));
}
}