You are here

public static function UbercartAttributeTestCase::createAttributeOption in Ubercart 7.3

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

Creates an attribute option.

Parameters

$data:

$save:

13 calls to UbercartAttributeTestCase::createAttributeOption()
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::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.
UbercartAttributeTestCase::testAttributeUIAttributeOptionsDelete in uc_attribute/tests/uc_attribute.test
Tests the "delete attribute option" user interface.

... See full list

File

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

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public static function createAttributeOption($data = array(), $save = TRUE) {
  $max_aid = db_select('uc_attributes', 'a')
    ->fields('a', array(
    'aid',
  ))
    ->orderBy('aid', 'DESC')
    ->range(0, 1)
    ->execute()
    ->fetchField();
  $option = $data + array(
    'aid' => $max_aid,
    '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;
}