You are here

protected function UCDropdownAttributesTestCase::createProduct in Dropdown Attributes 7

Creates a new product.

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

File

tests/uc_dropdown_attributes.test, line 249
Tests for Dropdown Attributes.

Class

UCDropdownAttributesTestCase
Provides tests for Dropdown Attributes.

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