You are here

public function UbercartAttributeTestCase::testAttributeUISettings in Ubercart 7.3

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

Tests the attribute settings page.

File

uc_attribute/tests/uc_attribute.test, line 356
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);
  $qty = $product->default_qty;
  if (!$qty) {
    $qty = 1;
  }
  $adjust_price = uc_currency_format($option->price * $qty);
  $total_price = uc_currency_format(($product->sell_price + $option->price) * $qty);
  $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/products', $edit, t('Save configuration'));
    $this
      ->drupalGet('node/' . $product->nid);
    $this
      ->assertRaw($raw[$type], t('Attribute option pricing is correct.'));
  }
}