89 lines
2.5 KiB
PHP
89 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\DropshipBundle\Tests;
|
|
|
|
use KupShop\DropshipBundle\Transfer\ExpandoTransfer;
|
|
|
|
class TransferRestrictionsTest extends \DatabaseTestCase
|
|
{
|
|
public function testEmptyDropshipment(): void
|
|
{
|
|
$xml = simplexml_load_file(__DIR__.'/files/xml_order_1.xml');
|
|
|
|
/** @var ExpandoTransfer $dropshipment */
|
|
$dropshipment = $this->get(ExpandoTransfer::class);
|
|
$this->assertEquals(true, $dropshipment->isValidRestrictionByTag($xml));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideCases
|
|
*/
|
|
public function testRestrictions(array $restrictions, bool $isValid): void
|
|
{
|
|
$xml = simplexml_load_file(__DIR__.'/files/xml_order_1.xml');
|
|
|
|
/** @var ExpandoTransfer $dropshipment */
|
|
$dropshipment = $this->get(ExpandoTransfer::class);
|
|
$dropshipment->dropshipment['data']['restrictions'] = $restrictions;
|
|
$this->assertEquals($isValid, $dropshipment->isValidRestrictionByTag($xml));
|
|
}
|
|
|
|
public function provideCases(): \Generator
|
|
{
|
|
yield 'empty restrictions' => [
|
|
'restrictions' => [],
|
|
'isValid' => true,
|
|
];
|
|
|
|
yield 'single invalid value in tagName' => [
|
|
'restrictions' => [
|
|
'tagName' => 'marketplace',
|
|
'values' => 'AMAZON ES',
|
|
],
|
|
'isValid' => false,
|
|
];
|
|
|
|
yield 'match case-sensitive case in values (preventive for AMAZON Uk)' => [
|
|
'restrictions' => [
|
|
'tagName' => 'marketplace',
|
|
'values' => 'aMaZoN ES',
|
|
],
|
|
'isValid' => false,
|
|
];
|
|
|
|
yield 'restriction value => out of range' => [
|
|
'restrictions' => [
|
|
'tagName' => 'marketplace',
|
|
'values' => 'AMAZON UK',
|
|
],
|
|
'isValid' => true,
|
|
];
|
|
|
|
yield 'tagName change => match value' => [
|
|
'restrictions' => [
|
|
'tagName' => 'fulfillmentChannel',
|
|
'values' => 'FBA',
|
|
],
|
|
'isValid' => false,
|
|
];
|
|
|
|
yield 'tagName change => unmatch value' => [
|
|
'restrictions' => [
|
|
'tagName' => 'fulfillmentChannel',
|
|
'values' => 'FBAA',
|
|
],
|
|
'isValid' => true,
|
|
];
|
|
|
|
yield 'tagName does not exists' => [
|
|
'restrictions' => [
|
|
'tagName' => 'foofoofoo',
|
|
'values' => 'FBA',
|
|
],
|
|
'isValid' => true,
|
|
];
|
|
}
|
|
}
|