public function UbercartAttributeTestCase::testAttributeUIClassAttributeOptionOverview in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.test \UbercartAttributeTestCase::testAttributeUIClassAttributeOptionOverview()
Tests the product class attribute option user interface.
File
- uc_attribute/
tests/ uc_attribute.test, line 601 - Ubercart Attribute Tests.
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUIClassAttributeOptionOverview() {
$class = $this
->createProductClass();
$attribute = self::createAttribute();
$option = self::createAttributeOption(array(
'aid' => $attribute->aid,
));
uc_attribute_subject_save($attribute, 'class', $class->pcid);
$this
->drupalGet('admin/store/products/classes/' . $class->pcid . '/options');
$this
->assertRaw(t('@option </label>', array(
'@option' => $option->name,
)), t('Class attribute option form working.'));
$o = (array) self::createAttributeOption(array(
'aid' => $attribute->aid,
), FALSE);
unset($o['name'], $o['aid']);
$o['select'] = TRUE;
foreach ($o as $field => $value) {
$edit["attributes[{$attribute->aid}][options][{$option->oid}][{$field}]"] = $value;
}
unset($o['select']);
$edit["attributes[{$attribute->aid}][default]"] = $option->oid;
$this
->showVar($edit);
$this
->drupalPost('admin/store/products/classes/' . $class->pcid . '/options', $edit, t('Submit'));
$this
->assertText('The product class options have been saved.', t('Class attribute option saved.'));
$this
->showVar($option);
$option = uc_attribute_subject_option_load($option->oid, 'class', $class->pcid);
$fields_ok = TRUE;
foreach ($o as $field => $value) {
if ($option->{$field} != $value) {
$this
->showVar($option);
$this
->showVar($o);
$fields_ok = FALSE;
break;
}
}
$this
->assertTrue($fields_ok, t('Class attribute option edited successfully by form.'));
}