You are here

public function SwissVatTest::testApplication in Commerce Core 8.2

@covers ::applies @covers ::apply

Overrides EuropeanUnionVatTest::testApplication

File

modules/tax/tests/src/Kernel/Plugin/Commerce/TaxType/SwissVatTest.php, line 36

Class

SwissVatTest
@coversDefaultClass \Drupal\commerce_tax\Plugin\Commerce\TaxType\SwissVat @group commerce

Namespace

Drupal\Tests\commerce_tax\Kernel\Plugin\Commerce\TaxType

Code

public function testApplication() {
  $plugin = $this->taxType
    ->getPlugin();

  // Swiss customer, Swiss store, standard VAT.
  $order = $this
    ->buildOrder('CH', 'CH');
  $this
    ->assertTrue($plugin
    ->applies($order));
  $plugin
    ->apply($order);
  $adjustments = $order
    ->collectAdjustments();
  $adjustment = reset($adjustments);
  $this
    ->assertCount(1, $adjustments);
  $this
    ->assertEquals('swiss_vat|ch|standard', $adjustment
    ->getSourceId());

  // Liechtenstein customer, Swiss store, standard VAT.
  $order = $this
    ->buildOrder('LI', 'CH');
  $this
    ->assertTrue($plugin
    ->applies($order));
  $plugin
    ->apply($order);
  $adjustments = $order
    ->collectAdjustments();
  $adjustment = reset($adjustments);
  $this
    ->assertCount(1, $adjustments);
  $this
    ->assertEquals('swiss_vat|ch|standard', $adjustment
    ->getSourceId());

  // Serbian customer, Swiss store, no VAT.
  $order = $this
    ->buildOrder('RS', 'CH');
  $this
    ->assertTrue($plugin
    ->applies($order));
  $plugin
    ->apply($order);
  $adjustments = $order
    ->collectAdjustments();
  $this
    ->assertCount(0, $adjustments);
}