You are here

public static function UbercartAttributeTestCase::createAttribute in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.test \UbercartAttributeTestCase::createAttribute()

Creates an attribute.

Parameters

$data:

$save:

18 calls to UbercartAttributeTestCase::createAttribute()
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::testAttributeUIAddAttribute in uc_attribute/tests/uc_attribute.test
Tests the "add attribute" user interface.
UbercartAttributeTestCase::testAttributeUIAttributeOptions in uc_attribute/tests/uc_attribute.test
Tests the attribute options user interface.
UbercartAttributeTestCase::testAttributeUIAttributeOptionsAdd in uc_attribute/tests/uc_attribute.test
Tests the "add attribute option" user interface.

... See full list

File

uc_attribute/tests/uc_attribute.test, line 831
Ubercart Attribute Tests.

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public static 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;
}