public function CommerceTaxUIAdminTest::testCommerceTaxUIApplyVAT in Commerce Core 7
Check if a 'VAT' tax type is correctly applied in a given product.
File
- modules/
tax/ tests/ commerce_tax_ui.test, line 596 - Functional tests for the commerce tax UI module.
Class
- CommerceTaxUIAdminTest
- Functional tests for the commerce tax UI module.
Code
public function testCommerceTaxUIApplyVAT() {
// Create a tax rate VAT Type.
$tax_rate = $this
->createDummyTaxRate(array(
'type' => 'vat',
));
// Create a new product and product display.
$this
->createDummyProductDisplayContentType();
$product = $this
->createDummyProduct();
$product_wrapper = entity_metadata_wrapper('commerce_product', $product);
$product_node = $this
->createDummyProductNode(array(
$product->product_id,
));
// Login with normal user.
$this
->drupalLogin($this->normal_user);
// Go to the product display and check if the tax is applied.
$this
->drupalGet('node/' . $product_node->nid);
// Check the tax applied in database and product display.
$products = commerce_product_load_multiple(array(
$product->product_id,
), array(), TRUE);
$product = reset($products);
$price_component = commerce_product_calculate_sell_price($product);
$this
->assertText(trim(commerce_currency_format($price_component['amount'], $price_component['currency_code'])), t('Amount with taxes corresponds with the amount displayed in the product display page'));
$components = commerce_price_component_load($price_component, $tax_rate['price_component']);
$tax_component = reset($components);
$this
->assertFalse(empty($tax_component), t('Tax component is set in the product.'));
}