public function CommerceTaxUIAdminTest::testCommerceTaxUIUserOrderView in Commerce Core 7
Check the taxes applied in the order that a normal user can view.
File
- modules/
tax/ tests/ commerce_tax_ui.test, line 700 - Functional tests for the commerce tax UI module.
Class
- CommerceTaxUIAdminTest
- Functional tests for the commerce tax UI module.
Code
public function testCommerceTaxUIUserOrderView() {
// Create a tax rate.
$tax_rate = $this
->createDummyTaxRate(array(
'type' => 'sales_tax',
));
// Create new order and products associated to it.
$order = $this
->createDummyOrder($this->normal_user->uid);
// Login with normal user.
$this
->drupalLogin($this->normal_user);
// Go through the complete order process.
$this
->commerceTaxHelperCompleteCheckout();
// Access the View orders page and view the order just created.
$this
->drupalGet('user/' . $this->normal_user->uid . '/orders/' . $order->order_id);
// Reload the order directly from db.
$orders = commerce_order_load_multiple(array(
$order->order_id,
), array(), TRUE);
$order = reset($orders);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$components = commerce_price_component_load($order_wrapper->commerce_order_total
->value(), $tax_rate['price_component']);
$tax_component = reset($components);
// Check the taxes applied.
$this
->assertText($tax_rate['display_title'], t('Tax display title is displayed in the user view of an order.'));
$this
->assertText(trim(commerce_currency_format($tax_component['price']['amount'], $tax_component['price']['currency_code'])), t('Tax amount is displayed in the user view of an order.'));
}