You are here

public function UbercartAttributeTestCase::testAttributeUIEditAttribute in Ubercart 7.3

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

Tests the "edit attribute" user interface.

File

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

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public function testAttributeUIEditAttribute() {
  $attribute = self::createAttribute();
  $this
    ->drupalGet('admin/store/products/attributes/' . $attribute->aid . '/edit');
  $this
    ->assertText(t('Edit attribute: @name', array(
    '@name' => $attribute->name,
  )), t('Attribute edit form working.'));
  $edit = (array) self::createAttribute(array(), FALSE);
  $this
    ->drupalPost('admin/store/products/attributes/' . $attribute->aid . '/edit', $edit, t('Submit'));
  $attribute = uc_attribute_load($attribute->aid);
  $fields_ok = TRUE;
  foreach ($edit as $field => $value) {
    if ($attribute->{$field} != $value) {
      $this
        ->showVar($attribute);
      $this
        ->showVar($edit);
      $fields_ok = FALSE;
      break;
    }
  }
  $this
    ->assertTrue($fields_ok, t('Attribute edited properly.'));
}