You are here

public static function DropdownAttributeTestCase::createAttributeOption in Dropdown Attributes 6

Creates an attribute option.

Parameters

$data:

$save:

2 calls to DropdownAttributeTestCase::createAttributeOption()
DropdownAttributeTestCase::testClassAttributeDependency in tests/uc_dropdown_attributes.test
Tests for dropdown attributes in product classes.
DropdownAttributeTestCase::testProductAttributeDependency in tests/uc_dropdown_attributes.test
Tests for dropdown attributes in products.

File

tests/uc_dropdown_attributes.test, line 209
Dropdown Attribute Tests

Class

DropdownAttributeTestCase
Tests for Dropdown Attributes.

Code

public static function createAttributeOption($data = array(), $save = TRUE) {
  $option = $data + array(
    'name' => DrupalWebTestCase::randomName(8),
    'cost' => mt_rand(-500, 500),
    'price' => mt_rand(-500, 500),
    'weight' => mt_rand(-500, 500),
    'ordering' => mt_rand(-10, 10),
  );
  $option = (object) $option;
  if ($save) {
    uc_attribute_option_save($option);
  }
  return $option;
}