public function TaxTypePluginTest::testDisableCommitTransaction in Drupal Commerce Connector for AvaTax 8
Tests that a transaction is not committed when configured to skip.
File
- tests/
src/ Kernel/ TaxTypePluginTest.php, line 300
Class
- TaxTypePluginTest
- Tests the tax type plugin.
Namespace
Drupal\Tests\commerce_avatax\KernelCode
public function testDisableCommitTransaction() {
$this
->config(self::CONFIG_NAME)
->set('disable_commit', TRUE)
->save();
$this
->mockResponse([
new Response(200, [], Json::encode([
'lines' => [
[
'lineNumber' => 1,
'tax' => 5.25,
],
],
])),
new Response(200, [], Json::encode([
'lines' => [
[
'lineNumber' => 1,
'tax' => 5.25,
],
],
])),
], [
function (callable $handler) {
return function (RequestInterface $request, array $options) use ($handler) {
$count = \Drupal::state()
->get('avatax_request_count', 0);
$count++;
\Drupal::state()
->set('avatax_request_count', $count);
return $handler($request, $options);
};
},
]);
$this->taxType
->getPlugin()
->apply($this->order);
$adjustments = $this->order
->collectAdjustments();
$this
->assertCount(1, $adjustments);
$transition = $this->order
->getState()
->getTransitions()['place'];
$this->order
->getState()
->applyTransition($transition);
$this->order
->save();
$this
->assertEquals(1, $this->container
->get('state')
->get('avatax_request_count'));
}