public function ExchangeRateTest::testCreateFromExchangeRate in Currency 8.3
@covers ::createFromExchangeRate
File
- tests/
src/ Unit/ ExchangeRateTest.php, line 38
Class
- ExchangeRateTest
- @coversDefaultClass \Drupal\currency\ExchangeRate
Namespace
Drupal\Tests\currency\UnitCode
public function testCreateFromExchangeRate() {
$exchange_rate_provider_id = $this
->randomMachineName();
$timestamp = mt_rand();
$source_currency_code = $this
->randomMachineName(3);
$destination_currency_code = $this
->randomMachineName(3);
$rate = mt_rand();
$other_exchange_rate = new GenericExchangeRate($source_currency_code, $destination_currency_code, $rate);
$other_exchange_rate
->setTimestamp($timestamp);
$created_exchange_rate = ExchangeRate::createFromExchangeRate($other_exchange_rate, $exchange_rate_provider_id);
$this
->assertSame($other_exchange_rate
->getSourceCurrencyCode(), $created_exchange_rate
->getSourceCurrencyCode());
$this
->assertSame($other_exchange_rate
->getDestinationCurrencyCode(), $created_exchange_rate
->getDestinationCurrencyCode());
$this
->assertSame($other_exchange_rate
->getRate(), $created_exchange_rate
->getRate());
$this
->assertSame($other_exchange_rate
->getTimestamp(), $created_exchange_rate
->getTimestamp());
$this
->assertSame($exchange_rate_provider_id, $created_exchange_rate
->getExchangeRateProviderId());
}