protected function UbercartTestHelper::createProduct in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_store/uc_store.test \UbercartTestHelper::createProduct()
Creates a new product.
19 calls to UbercartTestHelper::createProduct()
- UbercartAjaxTestCase::testCheckoutAjax in uc_store/
tests/ uc_ajax.test - UbercartAttributeCheckoutTestCase::testAttributeAddToCart in uc_attribute/
tests/ uc_attribute_checkout.test - Tests that product in cart has the selected attribute option.
- UbercartAttributeTestCase::testAttributeAPI in uc_attribute/
tests/ uc_attribute.test - Tests the basic attribute API.
- UbercartAttributeTestCase::testAttributeUIProductAdjustments in uc_attribute/
tests/ uc_attribute.test - Tests the "product adjustments" page.
- UbercartAttributeTestCase::testAttributeUIProductAttributes in uc_attribute/
tests/ uc_attribute.test - Tests the "product attributes" page.
File
- uc_store/
tests/ uc_store.test, line 64 - Test functionality provided by uc_store.
Class
- UbercartTestHelper
- Defines a base helper class for Ubercart tests.
Code
protected function createProduct($product = array()) {
// Set the default required fields.
$weight_units = array(
'lb',
'kg',
'oz',
'g',
);
$length_units = array(
'in',
'ft',
'cm',
'mm',
);
$product += array(
'type' => 'product',
'model' => $this
->randomName(8),
'list_price' => mt_rand(1, 9999),
'cost' => mt_rand(1, 9999),
'sell_price' => mt_rand(1, 9999),
'weight' => mt_rand(1, 9999),
'weight_units' => array_rand(array_flip($weight_units)),
'length' => mt_rand(1, 9999),
'width' => mt_rand(1, 9999),
'height' => mt_rand(1, 9999),
'length_units' => array_rand(array_flip($length_units)),
'pkg_qty' => mt_rand(1, 99),
'default_qty' => 1,
'ordering' => mt_rand(-25, 25),
'shippable' => TRUE,
);
return $this
->drupalCreateNode($product);
}