Skip to content

EspoCRM – Open Source CRM Application

fix test

Yuri Kuznetsov3173150d19f5
diff --git a/tests/integration/Espo/Currency/CurrencyTest.php b/tests/integration/Espo/Currency/CurrencyTest.php
index e9b1aedaa5..d39518aaa0 100644
--- a/tests/integration/Espo/Currency/CurrencyTest.php
+++ b/tests/integration/Espo/Currency/CurrencyTest.php
@@ -30,12 +30,13 @@
namespace tests\integration\Espo\Currency;
use Espo\Core\Exceptions\Error;
+use Espo\Core\Field\Date;
use Espo\Core\Formula\Manager as FormulaManager;
use Espo\Modules\Crm\Entities\Lead;
+use Espo\Tools\Currency\RateEntryProvider;
use Espo\Tools\Currency\RateService;
use Espo\Core\Currency\Rates;
use Espo\Core\Field\Currency;
-use Espo\Core\InjectableFactory;
use Espo\Core\Utils\Config\ConfigWriter;
use Espo\Tools\Currency\SyncManager;
use tests\integration\Core\BaseTestCase;
@@ -140,19 +141,34 @@ class CurrencyTest extends BaseTestCase
$this->assertEquals(null, $value);
}
+ /**
+ * @noinspection PhpUnhandledExceptionInspection
+ */
public function testFormulaConvert(): void
{
$formulaManager = $this->getContainer()->getByClass(FormulaManager::class);
+ $em = $this->getEntityManager();
$configWriter = $this->getInjectableFactory()->create(ConfigWriter::class);
$configWriter->set('currencyList', ['USD', 'EUR']);
$configWriter->set('defaultCurrency', 'USD');
$configWriter->set('baseCurrency', 'USD');
- $configWriter->set('currencyRates', [
- 'EUR' => 2.0,
- ]);
- $configWriter->save();
+ $configWriter->save();;
+
+ $syncManager = $this->getInjectableFactory()->create(SyncManager::class);
+
+ $syncManager->sync();
+
+ $rate = $this->getInjectableFactory()->create(RateEntryProvider::class)
+ ->prepareNew('EUR', Date::createToday()->addDays(-2));
+
+ $rate->setRate('2.0');
+
+ $em->saveEntity($rate);
+
+
+ $syncManager->refreshCache();
$script = "ext\\currency\\convert('0.5', 'EUR')";
$value = $formulaManager->run($script);