public function CommerceBaseTestCase::createDummyTaxRate in Commerce Core 7
* Create a dummy tax rate. * *
Parameters
$tax_type: * Array with the specific elements for the tax rate, all elements not * specified and required will be generated randomly. * @see hook_commerce_tax_rate_info * * @return * The tax type array just created or FALSE if it wasn't created.
11 calls to CommerceBaseTestCase::createDummyTaxRate()
- CommerceBaseTesterTestCase::testTestCreateDummyTaxRate in tests/
commerce_base.test - Test creating a new tax rate.
- CommerceTaxUIAdminTest::testCommerceTaxUIAdminOrder in modules/
tax/ tests/ commerce_tax_ui.test - Check the taxes applied in the order admin view.
- CommerceTaxUIAdminTest::testCommerceTaxUIApplySalesTax in modules/
tax/ tests/ commerce_tax_ui.test - Check if a 'Salex tax' rate is correctly applied in a given order.
- CommerceTaxUIAdminTest::testCommerceTaxUIApplyVAT in modules/
tax/ tests/ commerce_tax_ui.test - Check if a 'VAT' tax type is correctly applied in a given product.
- CommerceTaxUIAdminTest::testCommerceTaxUIApplyVATInclusive in modules/
tax/ tests/ commerce_tax_ui.test - Check if a 'VAT' tax type is correctly applied in a given product.
File
- tests/
commerce_base.test, line 556 - Defines abstract base test class for the Commerce module tests.
Class
- CommerceBaseTestCase
- Abstract class for Commerce testing. All Commerce tests should extend this class.
Code
public function createDummyTaxRate($tax_rate = array()) {
$defaults = array(
'name' => 'example_tax_rate',
'title' => t('Example tax rate'),
'display_title' => t('Example tax rate'),
'rate' => rand(1, 100) / 1000,
'type' => 'example_tax_type',
);
// Generate a tax type array based on defaults and specific elements.
$tax_rate = array_merge(commerce_tax_ui_tax_rate_new(), $defaults, $tax_rate);
if (commerce_tax_ui_tax_rate_save($tax_rate)) {
return commerce_tax_rate_load($tax_rate['name']);
}
else {
return FALSE;
}
}