first commit
This commit is contained in:
55
tests/functional/CNBTest.php
Normal file
55
tests/functional/CNBTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user