public function ExchangerRemoteProviderTest::testValidFiltered in Commerce Exchanger 8
@covers ::__construct @covers ::getBaseCurrency @covers ::getRates @covers ::isTransform @covers ::getCurrencies
File
- tests/
src/ Kernel/ ExchangerRemoteProviderTest.php, line 61
Class
- ExchangerRemoteProviderTest
- @coversDefaultClass \Drupal\commerce_exchanger\ExchangerProviderRates @group commerce_exchanger
Namespace
Drupal\Tests\commerce_exchanger\KernelCode
public function testValidFiltered() {
// Can't use a unit test because DrupalDateTime objects use \Drupal.
$definition = [
'base' => 'HRK',
'rates' => [
'EUR' => '7.55',
'USD' => '6.45',
'UAH' => '5.40',
],
'currencies' => [
'EUR' => 'Euro',
'USD' => 'Dolar',
'HRK' => 'Croatian Kuna',
],
'transform' => TRUE,
];
$rates = new ExchangerProviderRates($definition);
$this
->assertEquals($definition['base'], $rates
->getBaseCurrency());
$this
->assertNotEqual($definition['rates'], $rates
->getRates());
$this
->assertTrue($rates
->isTransform());
$this
->assertCount(3, $rates
->getCurrencies());
$this
->assertNotEqual($definition['rates']['EUR'], $rates
->getRates()['EUR']);
$this
->assertEqual(round(1 / 7.55, 6), $rates
->getRates()['EUR']);
$this
->assertEqual(2, count($rates
->getRates()));
}