42 lines
1.6 KiB
PHP
42 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\LingxingErp\Test\Unit\Model;
|
|
|
|
use Esun\LingxingErp\Model\Config;
|
|
use Magento\Framework\App\Config\ScopeConfigInterface;
|
|
use Magento\Framework\Encryption\EncryptorInterface;
|
|
use Magento\Store\Model\ScopeInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ConfigTest extends TestCase
|
|
{
|
|
public function testStoreMappingIsResolvedPerWebsite(): void
|
|
{
|
|
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
|
$scopeConfig->method('getValue')->willReturnCallback(
|
|
static function (string $path, string $scope = 'default', $scopeCode = null): string {
|
|
if ($path !== 'esun_lingxing/general/store_mapping' || $scope !== ScopeInterface::SCOPE_WEBSITE) {
|
|
return '';
|
|
}
|
|
return (int)$scopeCode === 1 ? '10009|STORE-US' : '10002|STORE-EU';
|
|
}
|
|
);
|
|
$config = new Config($scopeConfig, $this->createMock(EncryptorInterface::class));
|
|
|
|
self::assertSame(10009, $config->getPlatformCode(1));
|
|
self::assertSame('STORE-US', $config->getLingxingStoreId(1));
|
|
self::assertSame(10002, $config->getPlatformCode(2));
|
|
self::assertSame('STORE-EU', $config->getLingxingStoreId(2));
|
|
}
|
|
|
|
public function testSkuSyncPageSizeIsBounded(): void
|
|
{
|
|
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
|
$scopeConfig->method('getValue')->with('esun_lingxing/sku_sync/page_size')->willReturn('500');
|
|
$config = new Config($scopeConfig, $this->createMock(EncryptorInterface::class));
|
|
|
|
self::assertSame(200, $config->getSkuSyncPageSize());
|
|
}
|
|
}
|