public function UbercartAttributeTestCase::testAttributeUIClassAttributeOverview in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_attribute/tests/uc_attribute.test \UbercartAttributeTestCase::testAttributeUIClassAttributeOverview()
Tests the product class attribute user interface.
File
- uc_attribute/
uc_attribute.test, line 614 - Ubercart Attribute Tests
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUIClassAttributeOverview() {
$class = $this
->createProductClass();
$attribute = self::createAttribute();
$this
->drupalGet('admin/store/products/classes/' . $class->pcid . '/attributes');
$this
->assertText(t('You must first add attributes to this class.'), t('Class attribute form working.'), t('Ubercart'));
uc_attribute_subject_save($attribute, 'class', $class->pcid);
$this
->drupalGet('admin/store/products/classes/' . $class->pcid . '/attributes');
$this
->assertNoText(t('You must first add attributes to this class.'), t('Class attribute form working.'), t('Ubercart'));
$a = (array) self::createAttribute(array(), FALSE);
unset($a['name'], $a['description']);
foreach ($a as $field => $value) {
$edit["attributes[{$attribute->aid}][{$field}]"] = $value;
}
$this
->showVar($edit);
$this
->drupalPost('admin/store/products/classes/' . $class->pcid . '/attributes', $edit, t('Save changes'));
$attribute = uc_attribute_load($attribute->aid, $class->pcid, 'class');
$fields_ok = TRUE;
foreach ($a as $field => $value) {
if ($attribute->{$field} != $value) {
$this
->showVar($attribute);
$this
->showVar($a);
$fields_ok = FALSE;
break;
}
}
$this
->assertTrue($fields_ok, t('Class attribute edited successfully by form.'), t('Ubercart'));
$edit = array();
$edit["attributes[{$attribute->aid}][remove]"] = TRUE;
$this
->drupalPost('admin/store/products/classes/' . $class->pcid . '/attributes', $edit, t('Save changes'));
$this
->assertText(t('You must first add attributes to this class.'), t('Class attribute form working.'), t('Ubercart'));
}