93 lines
3.6 KiB
PHP
93 lines
3.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: ondra
|
|
* Date: 14.2.18
|
|
* Time: 9:17.
|
|
*/
|
|
|
|
namespace KupShop\OSSVatsBundle\Tests;
|
|
|
|
use KupShop\DevelopmentBundle\Util\Tests\CartTestTrait;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
|
|
class OSSDeliveryTest extends \DatabaseTestCase
|
|
{
|
|
use CartTestTrait;
|
|
|
|
protected $contextManager;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$dbcfg = \Settings::getDefault();
|
|
$dbcfg->oss_vats['homeCountry'] = 'CZ';
|
|
$dbcfg->oss_vats['active'] = 'Y';
|
|
$this->contextManager = ServiceContainer::getService(\KupShop\KupShopBundle\Context\ContextManager::class);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider data_deliveryPriceDontCountinFrom
|
|
*/
|
|
public function testDeliveryPriceDontCountinFrom(
|
|
string $country,
|
|
int $productId,
|
|
int $deliveryType,
|
|
int $expectedDeliveryPrice,
|
|
bool $logged,
|
|
string $message,
|
|
): void {
|
|
if ($logged) {
|
|
$this->loginUser(1);
|
|
}
|
|
$this->createCart();
|
|
|
|
$this->insertProduct($productId);
|
|
$this->setDeliveryType($deliveryType);
|
|
|
|
$this->cart->updateAddresses(
|
|
[
|
|
'email' => 'test@wpj.cz',
|
|
'name' => 'Wpj',
|
|
'surname' => 'Wpj',
|
|
'street' => 'Wpj 123',
|
|
'city' => 'Vrchlabi',
|
|
'zip' => 12345,
|
|
'country' => $country,
|
|
'phone' => '123456789',
|
|
],
|
|
null
|
|
);
|
|
$this->cart->createFromDB();
|
|
$this->assertEquals(
|
|
$expectedDeliveryPrice,
|
|
$this->cart->getDeliveryType()->getDelivery()->getPrice()->getPriceWithVat()->asFloat(),
|
|
$message
|
|
);
|
|
}
|
|
|
|
public function data_deliveryPriceDontCountinFrom(): array
|
|
{
|
|
return [
|
|
['CZ', 3, 2, 99, false, 'Delivery dont_countin_from is 99 Kc, item price is 91 Kc. Delivery should not be free.'],
|
|
['CZ', 2, 2, 0, false, 'Delivery dont_countin_from is 99 Kc, item price is 99 Kc. Delivery should be free.'],
|
|
['CZ', 4, 2, 99, false, 'Delivery dont_countin_from is 99 Kc and dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is not logged. Delivery should not be free.'],
|
|
['CZ', 4, 2, 0, true, 'Delivery dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is logged. Delivery should be free.'],
|
|
['HR', 3, 2, 102, false, 'Delivery dont_countin_from is 99 Kc, item price is 91 Kc. Delivery should not be free.'],
|
|
['HR', 2, 2, 0, false, 'Delivery dont_countin_from is 99 Kc, item price is 99 Kc. Delivery should be free.'],
|
|
['HR', 4, 2, 102, false, 'Delivery dont_countin_from is 99 Kc and dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is not logged. Delivery should not be free.'],
|
|
['HR', 4, 2, 0, true, 'Delivery dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is logged. Delivery should be free.'],
|
|
['HU', 3, 2, 104, false, 'Delivery dont_countin_from is 99 Kc, item price is 91 Kc. Delivery should not be free.'],
|
|
['HU', 2, 2, 0, false, 'Delivery dont_countin_from is 99 Kc, item price is 99 Kc. Delivery should be free.'],
|
|
['HU', 4, 2, 104, false, 'Delivery dont_countin_from is 99 Kc and dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is not logged. Delivery should not be free.'],
|
|
['HU', 4, 2, 0, true, 'Delivery dont_countin_from_reg is 50 Kc, item price is 60 Kc and user is logged. Delivery should be free.'],
|
|
];
|
|
}
|
|
|
|
public function getDataSet()
|
|
{
|
|
return $this->getJsonDataSetFromFile();
|
|
}
|
|
}
|