protected function UCDropdownAttributesTestCase::createAttribute in Dropdown Attributes 7
Creates an attribute.
Parameters
array $data: Array of overrides.
bool $save: TRUE or FALSE.
2 calls to UCDropdownAttributesTestCase::createAttribute()
- UCDropdownAttributesTestCase::testClassAttributeDependency in tests/
uc_dropdown_attributes.test - Test for dropdown attributes in product classes.
- UCDropdownAttributesTestCase::testProductAttributeDependency in tests/
uc_dropdown_attributes.test - Test for dropdown attributes in products.
File
- tests/
uc_dropdown_attributes.test, line 199 - Tests for Dropdown Attributes.
Class
- UCDropdownAttributesTestCase
- Provides tests for Dropdown Attributes.
Code
protected function createAttribute($data = array(), $save = TRUE) {
$attribute = $data + array(
'name' => DrupalWebTestCase::randomName(8),
'label' => DrupalWebTestCase::randomName(8),
'description' => DrupalWebTestCase::randomName(8),
'required' => mt_rand(0, 1) ? TRUE : FALSE,
'display' => mt_rand(0, 3),
'ordering' => mt_rand(-10, 10),
);
$attribute = (object) $attribute;
if ($save) {
uc_attribute_save($attribute);
}
return $attribute;
}