public function UbercartAttributeTestCase::testAttributeUISettings in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_attribute/tests/uc_attribute.test \UbercartAttributeTestCase::testAttributeUISettings()
Tests the attribute settings page.
File
- uc_attribute/
uc_attribute.test, line 368 - Ubercart Attribute Tests
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUISettings() {
$product = $this
->createProduct();
$attribute = self::createAttribute(array(
'display' => 1,
));
$option = self::createAttributeOption(array(
'aid' => $attribute->aid,
'price' => 30,
));
$attribute->options[$option->oid] = $option;
uc_attribute_subject_save($attribute, 'product', $product->nid, TRUE);
$context = array(
'revision' => 'formatted',
'location' => 'product-attribute-form-element',
'subject' => array(
'attribute' => $attribute,
),
'extras' => array(
'option' => $option,
),
);
$qty = $product->default_qty;
if (!$qty) {
$qty = 1;
}
$price_info = array(
'price' => $option->price,
'qty' => $qty,
);
$adjust_price = uc_price($price_info, $context);
$price_info['price'] += $product->sell_price;
$total_price = uc_price($price_info, $context);
$raw = array(
'none' => $option->name . '</option>',
'adjustment' => $option->name . ', +' . $adjust_price . '</option>',
'total' => $total_price . '</option>',
);
foreach (array(
'none',
'adjustment',
'total',
) as $type) {
$edit['uc_attribute_option_price_format'] = $type;
$this
->drupalPost('admin/store/settings/attributes', $edit, t('Save configuration'));
$this
->drupalGet('node/' . $product->nid);
$this
->AssertRaw($raw[$type], t('Attribute option pricing is correct.'), t('Ubercart'));
}
}