You are here

public function ExchangerRemoteProviderTest::testValid in Commerce Exchanger 8

@covers ::__construct @covers ::getBaseCurrency @covers ::getRates @covers ::isTransform @covers ::getCurrencies

File

tests/src/Kernel/ExchangerRemoteProviderTest.php, line 36

Class

ExchangerRemoteProviderTest
@coversDefaultClass \Drupal\commerce_exchanger\ExchangerProviderRates @group commerce_exchanger

Namespace

Drupal\Tests\commerce_exchanger\Kernel

Code

public function testValid() {

  // Can't use a unit test because DrupalDateTime objects use \Drupal.
  $definition = [
    'base' => 'HRK',
    'rates' => [
      'EUR' => '7.55',
      'USD' => '6.45',
    ],
  ];
  $rates = new ExchangerProviderRates($definition);
  $this
    ->assertEquals($definition['base'], $rates
    ->getBaseCurrency());
  $this
    ->assertEquals($definition['rates'], $rates
    ->getRates());
  $this
    ->assertFalse($rates
    ->isTransform());
  $this
    ->assertCount(2, $rates
    ->getRates());
  $this
    ->assertEmpty($rates
    ->getCurrencies());
}