first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
use KupShop\KupShopBundle\Context\CurrencyContext;
class CNBTest extends \DatabaseTestCase
{
public function testCNBTest()
{
CNB::setUrl(__DIR__.'/CNBTest.txt');
CNB::updateSharedCurrencies();
CNB::updateCurrencies();
$context = $this->get(CurrencyContext::class);
$this->assertEquals('26.17', $context->getSupported()['EUR']->getRate()->asFloat());
}
public function testForeignCurrencyCNBTest()
{
$dbcfg = Settings::getDefault();
$dbcfg->currency = 'EUR';
$this->tearDownContainer();
/** @var CurrencyContext $context */
$context = $this->get(CurrencyContext::class);
$context->getSupported()['EUR']->setRate(toDecimal(1.02));
$context->getSupported()['CZK']->setRate(toDecimal(0.0380));
$context->getSupported()['CZK']->setSync('Y');
CNB::setUrl(__DIR__.'/CNBTest.txt');
CNB::updateSharedCurrencies();
CNB::updateCurrencies();
$context = $this->get(CurrencyContext::class);
$this->assertEquals('1', $context->getSupported()['EUR']->getRate()->asFloat());
$this->assertEqualsWithDelta(0.03821169277799, $context->getSupported()['CZK']->getRate()->asFloat(), 0.00000000000001);
}
public function testCNBCorrections()
{
/** @var CurrencyContext $context */
$context = $this->get(CurrencyContext::class);
$context->getSupported()['EUR']->setCorrections(toDecimal(0.83));
CNB::setUrl(__DIR__.'/CNBTest.txt');
CNB::updateSharedCurrencies();
CNB::updateCurrencies(true);
$this->assertEquals('27', $context->getSupported()['EUR']->getRate()->asFloat());
}
}