You are here

public function MinorUnitsConverterTest::testConversion in Commerce Core 8.2

Tests if price can be converted to minor unit and then back to decimal.

@dataProvider currencyConversionData

File

modules/price/tests/src/Unit/MinorUnitsConverterTest.php, line 55

Class

MinorUnitsConverterTest
Tests the MinorUnitsConverter class.

Namespace

Drupal\Tests\commerce_price\Unit

Code

public function testConversion(Price $price, $expected_amount) {
  $amount = $this->minorUnitsConverter
    ->toMinorUnits($price);
  $this
    ->assertEquals($expected_amount, $amount);
  $this
    ->assertTrue($this->minorUnitsConverter
    ->fromMinorUnits($amount, $price
    ->getCurrencyCode())
    ->equals($price));
}