You are here

public function UbercartAttributeTestCase::testAttributeUIProductOptions in Ubercart 7.3

Tests the "product options" page.

File

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

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public function testAttributeUIProductOptions() {
  $product = $this
    ->createProduct();
  $attribute = self::createAttribute(array(
    'display' => 1,
  ));
  for ($i = 0; $i < 3; $i++) {
    $option = self::createAttributeOption(array(
      'aid' => $attribute->aid,
    ));
    $attribute->options[$option->oid] = $option;
  }
  uc_attribute_subject_save($attribute, 'product', $product->nid, TRUE);
  $this
    ->drupalGet('node/' . $product->nid . '/edit/options');
  $this
    ->assertText($attribute->name, 'Attribute name found');
  foreach ($attribute->options as $option) {
    $this
      ->assertText($option->name, 'Option name found');
    $this
      ->assertFieldByName('attributes[' . $attribute->aid . '][options][' . $option->oid . '][cost]', $option->cost, 'Option cost field found');
    $this
      ->assertFieldByName('attributes[' . $attribute->aid . '][options][' . $option->oid . '][price]', $option->price, 'Option price field found');
    $this
      ->assertFieldByName('attributes[' . $attribute->aid . '][options][' . $option->oid . '][weight]', $option->weight, 'Option weight field found');
  }
}