This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Test\Unit\Model\Store;
use Esun\LingxingErp\Model\Api\ApiException;
use Esun\LingxingErp\Model\Api\Client;
use Esun\LingxingErp\Model\Store\StoreFetcher;
use PHPUnit\Framework\TestCase;
class StoreFetcherTest extends TestCase
{
public function testFetchesEveryPageWithoutStatusFilters(): void
{
$client = $this->createMock(Client::class);
$call = 0;
$client->expects(self::exactly(2))
->method('post')
->willReturnCallback(static function (string $path, array $parameters) use (&$call): array {
self::assertSame('/pb/mp/shop/v2/getSellerList', $path);
self::assertSame([
'offset' => $call,
'length' => 200,
'platform_code' => [10009],
], $parameters);
$response = ['data' => [
'total' => 2,
'list' => [[
'platform_code' => $call + 1,
'store_id' => $call === 0 ? 'A' : 'B',
]],
]];
$call++;
return $response;
});
self::assertSame(['A', 'B'], array_column((new StoreFetcher($client))->fetchAll(), 'store_id'));
}
public function testRejectsIncompleteStoreData(): void
{
$client = $this->createMock(Client::class);
$client->method('post')->willReturn([
'data' => ['total' => 1, 'list' => [['platform_code' => 1]]],
]);
$this->expectException(ApiException::class);
(new StoreFetcher($client))->fetchAll();
}
}