protected function CommerceReportsTaxGenerationTests::generateTax in Commerce Reporting 7.4
1 call to CommerceReportsTaxGenerationTests::generateTax()
- CommerceReportsTaxGenerationTests::testSingleTaxType in modules/
tax/ Tests/ CommerceReportsTaxGenerationTests.php - The following test is unfinished thanks to an apparent bug in SimpleTest.
File
- modules/
tax/ Tests/ CommerceReportsTaxGenerationTests.php, line 37
Class
Namespace
Drupal\commerce_reports_tax\TestsCode
protected function generateTax($amount = 1) {
// Create a tax rate of Salex Type.
$this
->createDummyTaxRate(array(
'' => '',
));
$taxed = array();
// Login with normal user.
$this
->drupalLogin($this->normal_user);
for ($i = 0; $i < $amount; $i++) {
// Create a dummy order in cart status.
$order = $this
->createDummyOrder($this->normal_user->uid);
// Get the checkout url and navigate to it.
$links = commerce_line_item_summary_links();
// Checkout order
$this
->drupalPost($links['checkout']['href'], array(
'customer_profile_billing[commerce_customer_address][und][0][name_line]' => $this
->randomName(),
'customer_profile_billing[commerce_customer_address][und][0][thoroughfare]' => $this
->randomName(),
'customer_profile_billing[commerce_customer_address][und][0][locality]' => $this
->randomName(),
), t('Continue to next step'));
$this
->drupalPost(NULL, array(
'commerce_payment[payment_details][name]' => $this
->randomName(),
), t('Continue to next step'));
$orders = commerce_order_load_multiple(array(
$order->order_id,
), array(), TRUE);
$order = reset($orders);
foreach ($order->commerce_order_total[LANGUAGE_NONE][0]['data']['components'] as $component) {
if (!empty($component['price']['data']['tax_rate'])) {
if (empty($taxed[$component['price']['data']['tax_rate']['name']])) {
$taxed[$component['price']['data']['tax_rate']['name']] = 0;
}
$taxed[$component['price']['data']['tax_rate']['name']] += $component['price']['amount'] / 100;
}
}
$this->orders[] = $order;
}
return $taxed;
}