public function UbercartAttributeTestCase::testAttributeUIAttributeOptionsAdd in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.test \UbercartAttributeTestCase::testAttributeUIAttributeOptionsAdd()
Tests the "add attribute option" user interface.
File
- uc_attribute/
tests/ uc_attribute.test, line 455 - Ubercart Attribute Tests.
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUIAttributeOptionsAdd() {
$attribute = self::createAttribute();
$this
->drupalGet('admin/store/products/attributes/' . $attribute->aid . '/options/add');
$this
->assertText(t('Options for @name', array(
'@name' => $attribute->name,
)), t('Attribute options add form working.'));
$edit = (array) self::createAttributeOption(array(
'aid' => $attribute->aid,
), FALSE);
unset($edit['aid']);
$this
->drupalPost('admin/store/products/attributes/' . $attribute->aid . '/options/add', $edit, t('Submit'));
$option = db_query("SELECT * FROM {uc_attribute_options} WHERE aid = :aid", array(
':aid' => $attribute->aid,
))
->fetchObject();
$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.'));
}