public function ClientFactoryTest::testClientFactory in Drupal Commerce Connector for AvaTax 8
Test that the Guzzle client is properly configured.
File
- tests/
src/ Kernel/ ClientFactoryTest.php, line 47
Class
- ClientFactoryTest
- Tests the API client factory.
Namespace
Drupal\Tests\commerce_avatax\KernelCode
public function testClientFactory() {
$client_factory = $this->container
->get('commerce_avatax.client_factory');
$client = $client_factory
->createInstance($this->config);
$this
->assertEquals('https://sandbox-rest.avatax.com/', $client
->getConfig('base_uri'));
$headers = $client
->getConfig('headers');
$this
->assertEquals('Basic ' . base64_encode($this->config['account_id'] . ':' . $this->config['license_key']), $headers['Authorization']);
$this
->assertEquals('a0o33000003waOC', $headers['x-Avalara-UID']);
$server_machine_name = gethostname();
$this
->assertEquals("Drupal Commerce; Version [8.x-1.x]; REST; V2; [{$server_machine_name}]", $headers['x-Avalara-Client']);
$this->config['api_mode'] = 'production';
$production_client = $client_factory
->createInstance($this->config);
$this
->assertEquals('https://rest.avatax.com/', $production_client
->getConfig('base_uri'));
}