class AvataxLibTest in Drupal Commerce Connector for AvaTax 8
Decorates `commerce_avatax.avatax_lib` for testing.
Hierarchy
- class \Drupal\commerce_avatax\AvataxLib implements AvataxLibInterface
- class \Drupal\commerce_avatax_test\AvataxLibTest
Expanded class hierarchy of AvataxLibTest
1 string reference to 'AvataxLibTest'
- commerce_avatax_test.services.yml in tests/
modules/ commerce_avatax_test/ commerce_avatax_test.services.yml - tests/modules/commerce_avatax_test/commerce_avatax_test.services.yml
1 service uses AvataxLibTest
- commerce_avatax_test.avatax_lib in tests/
modules/ commerce_avatax_test/ commerce_avatax_test.services.yml - Drupal\commerce_avatax_test\AvataxLibTest
File
- tests/
modules/ commerce_avatax_test/ src/ AvataxLibTest.php, line 11
Namespace
Drupal\commerce_avatax_testView source
class AvataxLibTest extends AvataxLib {
/**
* {@inheritdoc}
*/
public function resolveAddress(array $address) {
// Irvine.
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));
// In fixtures we have address which are fixed. We need to replace
// address array which represents what we are sending, so that
// mockup response could be valid.
$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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AvataxLib:: |
protected | property | The adjustment type manager. | |
AvataxLib:: |
protected | property | The cache backend. | |
AvataxLib:: |
protected | property | The chain tax code resolver. | |
AvataxLib:: |
protected | property | The client. | |
AvataxLib:: |
protected | property | The AvaTax configuration. | |
AvataxLib:: |
protected | property | The event dispatcher. | |
AvataxLib:: |
protected | property | The logger. | |
AvataxLib:: |
protected | property | The module handler. | |
AvataxLib:: |
protected | function | Performs an HTTP request to AvaTax. | |
AvataxLib:: |
protected static | function | Formats an address for use in the order request. | |
AvataxLib:: |
public static | function | Format an address with AvaTax array data. | |
AvataxLib:: |
public | function |
Prepares the transaction request body. (This method should not be public
but that makes the tests easier). Overrides AvataxLibInterface:: |
|
AvataxLib:: |
protected | function | Resolves the customer profile for the given order item. Stolen from TaxTypeBase::resolveCustomerProfile(). | |
AvataxLib:: |
public | function | Sets the http client. | |
AvataxLib:: |
public | function |
Creates a new transaction (/api/v2/transactions/create). Overrides AvataxLibInterface:: |
|
AvataxLib:: |
public | function |
Voids a transaction for the given order. Overrides AvataxLibInterface:: |
|
AvataxLib:: |
public | function |
Validate the give address from Drupal upon AvaTax resolved address. Overrides AvataxLibInterface:: |
|
AvataxLib:: |
public | function | Constructs a new AvataxLib object. | |
AvataxLibTest:: |
public | function |
Retrieve geolocation information for a specified address. Overrides AvataxLib:: |