You are here

public function UbercartAttributeTestCase::testAttributeUIAttributeOptionsEdit in Ubercart 6.2

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

Tests the "edit attribute options" user interface.

File

uc_attribute/uc_attribute.test, line 511
Ubercart Attribute Tests

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public function testAttributeUIAttributeOptionsEdit() {
  $attribute = self::createAttribute();
  $option = self::createAttributeOption(array(
    'aid' => $attribute->aid,
  ));
  uc_attribute_option_save($option);
  $this
    ->drupalGet('admin/store/attributes/' . $attribute->aid . '/options/' . $option->oid . '/edit');
  $this
    ->AssertText(t('Edit option: @name', array(
    '@name' => $option->name,
  )), t('Attribute options edit form working.'), t('Ubercart'));
  $edit = (array) self::createAttributeOption(array(
    'aid' => $attribute->aid,
  ), FALSE);
  unset($edit['aid']);
  $this
    ->drupalPost('admin/store/attributes/' . $attribute->aid . '/options/' . $option->oid . '/edit', $edit, t('Submit'));
  $option = uc_attribute_option_load($option->oid);
  $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 edited successfully by form.'), t('Ubercart'));
}