public function TaxTypePluginTest::testTaxCodeResolver in Drupal Commerce Connector for AvaTax 8
Tests the case code resolver.
File
- tests/
src/ Kernel/ TaxTypePluginTest.php, line 342
Class
- TaxTypePluginTest
- Tests the tax type plugin.
Namespace
Drupal\Tests\commerce_avatax\KernelCode
public function testTaxCodeResolver() {
$avatax_lib = $this->container
->get('commerce_avatax.avatax_lib');
$request_body = $avatax_lib
->prepareTransactionsCreate($this->order);
$this
->assertNull($request_body['lines'][0]['taxCode']);
$variation2 = ProductVariation::create([
'type' => 'default',
'sku' => 'TEST_' . strtolower($this
->randomMachineName()),
'title' => $this
->randomString(),
'status' => 1,
'price' => new Price('12.00', 'USD'),
'avatax_tax_code' => 'TESTCODE123',
]);
$variation2
->save();
$order_item = OrderItem::create([
'type' => 'default',
'quantity' => 1,
'unit_price' => new Price('12.00', 'USD'),
'purchased_entity' => $variation2,
]);
$order_item
->save();
$this->order
->addItem($order_item);
$this->order
->save();
$request_body = $avatax_lib
->prepareTransactionsCreate($this->order);
$this
->assertNull($request_body['lines'][0]['taxCode']);
$this
->assertEquals('TESTCODE123', $request_body['lines'][1]['taxCode']);
}