You are here

public function UbercartAttributeTestCase::testAttributeUIAttributeOptionsAdd in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_attribute/tests/uc_attribute.test \UbercartAttributeTestCase::testAttributeUIAttributeOptionsAdd()

Tests the "add attribute option" user interface.

File

uc_attribute/uc_attribute.test, line 481
Ubercart Attribute Tests

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public function testAttributeUIAttributeOptionsAdd() {
  $attribute = self::createAttribute();
  $this
    ->drupalGet('admin/store/attributes/' . $attribute->aid . '/options/add');
  $this
    ->AssertText(t('Options for @name', array(
    '@name' => $attribute->name,
  )), t('Attribute options add form working.'), t('Ubercart'));
  $edit = (array) self::createAttributeOption(array(
    'aid' => $attribute->aid,
  ), FALSE);
  unset($edit['aid']);
  $this
    ->drupalPost('admin/store/attributes/' . $attribute->aid . '/options/add', $edit, t('Submit'));
  $option = db_fetch_object(db_query("SELECT * FROM {uc_attribute_options} WHERE aid = %d", $attribute->aid));
  $fields_ok = TRUE;
  foreach ($edit as $field => $value) {
    if ($option->{$field} != $value) {
      $this
        ->showVar($option);
      $this
        ->showVar($edit);
      $fields_ok = FALSE;
      break;
    }
  }
  $this
    ->assertTrue($fields_ok, t('Attribute option added successfully by form.'), t('Ubercart'));
}