You are here

public function CommerceTaxUIAdminTest::testCommerceTaxUIAdminOrder in Commerce Core 7

Check the taxes applied in the order admin view.

File

modules/tax/tests/commerce_tax_ui.test, line 731
Functional tests for the commerce tax UI module.

Class

CommerceTaxUIAdminTest
Functional tests for the commerce tax UI module.

Code

public function testCommerceTaxUIAdminOrder() {

  // 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();

  // Login with store admin user.
  $this
    ->drupalLogin($this->store_admin);

  // Access the admin order edit page.
  $this
    ->drupalGet('admin/commerce/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 admin 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 admin view of an order.'));
}