You are here

function DropdownAttributeTestCase::createProduct in Dropdown Attributes 6

Creates a new product.

Overrides UbercartTestHelper::createProduct

1 call to DropdownAttributeTestCase::createProduct()
DropdownAttributeTestCase::testProductAttributeDependency in tests/uc_dropdown_attributes.test
Tests for dropdown attributes in products.

File

tests/uc_dropdown_attributes.test, line 238
Dropdown Attribute Tests

Class

DropdownAttributeTestCase
Tests for Dropdown Attributes.

Code

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);
}