You are here

public function TaxRatePercentageTest::testCalculation in Commerce Core 8.2

@covers ::calculateTaxAmount

File

modules/tax/tests/src/Kernel/TaxRatePercentageTest.php, line 67

Class

TaxRatePercentageTest
@coversDefaultClass \Drupal\commerce_tax\TaxRatePercentage @group commerce

Namespace

Drupal\Tests\commerce_tax\Kernel

Code

public function testCalculation() {
  $definition = [
    'number' => '0.20',
    'start_date' => '2012-01-01',
  ];
  $percentage = new TaxRatePercentage($definition);
  $tax_amount = $percentage
    ->calculateTaxAmount(new Price('12', 'USD'), FALSE);
  $this
    ->assertEquals(new Price('2.4', 'USD'), $tax_amount);
  $tax_amount = $percentage
    ->calculateTaxAmount(new Price('12', 'USD'), TRUE);
  $this
    ->assertEquals(new Price('2', 'USD'), $tax_amount);
}