protected function TaxTypePluginTest::mockResponse in Drupal Commerce Connector for AvaTax 8
Mock responses.
Parameters
\Psr\Http\Message\ResponseInterface[] $responses: An array of mocked responses.
array $middlewares: An array of callable handlers.
Throws
\Exception
7 calls to TaxTypePluginTest::mockResponse()
- TaxTypePluginTest::testApply in tests/
src/ Kernel/ TaxTypePluginTest.php - Tests applying.
- TaxTypePluginTest::testCommitTransaction in tests/
src/ Kernel/ TaxTypePluginTest.php - Tests that a transaction is committed when an order is placed.
- TaxTypePluginTest::testDisableCommitTransaction in tests/
src/ Kernel/ TaxTypePluginTest.php - Tests that a transaction is not committed when configured to skip.
- TaxTypePluginTest::testOrderAdjustments in tests/
src/ Kernel/ TaxTypePluginTest.php - Tests that order adjustments are correctly sent.
- TaxTypePluginTest::testRequestCaching in tests/
src/ Kernel/ TaxTypePluginTest.php - Test that the request is correctly cached.
File
- tests/
src/ Kernel/ TaxTypePluginTest.php, line 569
Class
- TaxTypePluginTest
- Tests the tax type plugin.
Namespace
Drupal\Tests\commerce_avatax\KernelCode
protected function mockResponse(array $responses = [], array $middlewares = []) {
$mock_handler = new MockHandler($responses);
$mock_handler_stack = HandlerStack::create($mock_handler);
foreach ($middlewares as $middleware) {
$mock_handler_stack
->push($middleware);
}
$config = $this
->config(self::CONFIG_NAME);
$mock_client = new Client([
'handler' => $mock_handler_stack,
'base_uri' => 'https://sandbox-rest.avatax.com/',
'headers' => [
'Authorization' => 'Basic ' . base64_encode($config
->get('account_id') . ':' . $config
->get('license_key')),
'Content-Type' => 'application/json',
'x-Avalara-UID' => 'a0o33000003waOC',
'x-Avalara-Client' => 'Test Client',
],
]);
$this->container
->get('commerce_avatax.avatax_lib')
->setClient($mock_client);
}