You are here

public function TaxTypePluginTest::testTaxExemptions in Drupal Commerce Connector for AvaTax 8

Test that the tax exemption type|number are correctly sent.

File

tests/src/Kernel/TaxTypePluginTest.php, line 443

Class

TaxTypePluginTest
Tests the tax type plugin.

Namespace

Drupal\Tests\commerce_avatax\Kernel

Code

public function testTaxExemptions() {
  $avatax_lib = $this->container
    ->get('commerce_avatax.avatax_lib');
  $request_body = $avatax_lib
    ->prepareTransactionsCreate($this->order);
  $this
    ->assertArrayNotHasKey('ExemptionNo', $request_body);
  $this
    ->assertArrayNotHasKey('CustomerUsageType', $request_body);
  $customer = $this->order
    ->getCustomer();
  $customer
    ->set('avatax_tax_exemption_number', 'XX');
  $customer
    ->save();
  $request_body = $avatax_lib
    ->prepareTransactionsCreate($this->order);
  $this
    ->assertArrayHasKey('ExemptionNo', $request_body);
  $this
    ->assertEquals('XX', $request_body['ExemptionNo']);
  $this
    ->assertArrayNotHasKey('CustomerUsageType', $request_body);
  $customer
    ->set('avatax_tax_exemption_type', 'A');
  $customer
    ->save();
  $request_body = $avatax_lib
    ->prepareTransactionsCreate($this->order);
  $this
    ->assertArrayHasKey('CustomerUsageType', $request_body);
  $this
    ->assertEquals('A', $request_body['CustomerUsageType']);
}