public function TaxTypePluginTest::testTransactionType in Drupal Commerce Connector for AvaTax 8
Tests that the transaction type is correct when applying the adjustment.
@link https://developer.avalara.com/avatax/dev-guide/transactions/should-i-com...
File
- tests/
src/ Kernel/ TaxTypePluginTest.php, line 223
Class
- TaxTypePluginTest
- Tests the tax type plugin.
Namespace
Drupal\Tests\commerce_avatax\KernelCode
public function testTransactionType() {
$this
->mockResponse([
new Response(200, [], Json::encode([
'lines' => [
[
'lineNumber' => 1,
'tax' => 5.25,
],
],
])),
], [
function (callable $handler) {
return function (RequestInterface $request, array $options) use ($handler) {
$body = $request
->getBody()
->getContents();
$body = Json::decode($body);
\Drupal::state()
->set('avatax_request_body', $body);
return $handler($request, $options);
};
},
]);
$this->taxType
->getPlugin()
->apply($this->order);
$request_body = $this->container
->get('state')
->get('avatax_request_body');
$this
->assertNotEmpty($request_body);
$this
->assertEquals('SalesOrder', $request_body['type'], 'Request transaction type is correct.');
}