AvataxLibTest.php in Drupal Commerce Connector for AvaTax 8
File
tests/modules/commerce_avatax_test/src/AvataxLibTest.php
View source
<?php
namespace Drupal\commerce_avatax_test;
use Drupal\commerce_avatax\AvataxLib;
use Drupal\Component\Serialization\Json;
class AvataxLibTest extends AvataxLib {
public function resolveAddress(array $address) {
if ($address['locality'] === 'Irvine') {
$file = drupal_get_path('module', 'commerce_avatax') . '/tests/fixtures/irvine.json';
if ($address['administrative_area'] === 'C0' || $address['address_line1'] === '2000 Main Stree') {
$file = drupal_get_path('module', 'commerce_avatax') . '/tests/fixtures/irvine_suggestion.json';
}
if ($address['address_line1'] === '20000 Main Street') {
$file = drupal_get_path('module', 'commerce_avatax') . '/tests/fixtures/irvine_error.json';
}
}
else {
$file = drupal_get_path('module', 'commerce_avatax') . '/tests/fixtures/durham.json';
if ($address['address_line1'] === '512 S Mangu' || $address['postal_code'] === '27001') {
$file = drupal_get_path('module', 'commerce_avatax') . '/tests/fixtures/durham_suggestion.json';
}
}
$response_body = Json::decode(file_get_contents($file));
$response_body['address'] = [
'line1' => $address['address_line1'],
'line2' => $address['address_line2'],
'city' => $address['locality'],
'region' => $address['administrative_area'],
'country' => $address['country_code'],
'postalCode' => $address['postal_code'],
];
return $response_body;
}
}