public function CommerceBaseTestCase::createDummyProductType in Commerce Core 7
Creates a dummy product type for use with other tests.
Return value
A product type. FALSE if the appropiate modules were not available.
3 calls to CommerceBaseTestCase::createDummyProductType()
- CommerceBaseTesterTestCase::testTestCreateDummyProductType in tests/
commerce_base.test - Make a test product type.
- CommerceProductReferenceAdminTest::testCommerceProductReferenceTestReferenceableTypes in modules/
product_reference/ tests/ commerce_product_reference.test - Test the limit of referenceable product types.
- CommerceProductUIAdminTest::setUp in modules/
product/ tests/ commerce_product_ui.test - Implementation of setUp().
File
- tests/
commerce_base.test, line 236 - 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 createDummyProductType($type = 'product_type', $name = 'Product Type', $description = '', $help = '', $append_random = TRUE) {
if (module_exists('commerce_product_ui')) {
if ($append_random) {
$type = $type . '_' . $this
->randomName(20 - strlen($type) - 1);
$name = $name . ' ' . $this
->randomName(40 - strlen($name) - 1);
$description = $description . ' ' . $this
->randomString(128);
$help = $help . ' ' . $this
->randomString(128);
}
$new_product_type = commerce_product_ui_product_type_new();
$new_product_type['type'] = $type;
$new_product_type['name'] = $name;
$new_product_type['description'] = $description;
$new_product_type['help'] = $help;
$new_product_type['is_new'] = TRUE;
$save_result = commerce_product_ui_product_type_save($new_product_type);
if ($save_result === FALSE) {
return FALSE;
}
return $new_product_type;
}
else {
return FALSE;
}
}