public function UbercartAttributeTestCase::testAttributeUIAddAttribute in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_attribute/tests/uc_attribute.test \UbercartAttributeTestCase::testAttributeUIAddAttribute()
Tests the "add attribute" user interface.
File
- uc_attribute/
uc_attribute.test, line 332 - Ubercart Attribute Tests
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUIAddAttribute() {
$this
->drupalGet('admin/store/attributes/add');
$this
->AssertText(t('The name of the attribute used in administrative forms'), t('Attribute add form working.'), t('Ubercart'));
$edit = (array) self::createAttribute(array(), FALSE);
$this
->drupalPost('admin/store/attributes/add', $edit, t('Submit'));
$this
->assertRaw('<td class="active">' . $edit['name'] . '</td>', t('Verify name field.'), t('Ubercart'));
$this
->assertRaw('<td>' . $edit['label'] . '</td>', t('Verify label field.'), t('Ubercart'));
$this
->assertRaw('<td>' . ($edit['required'] ? t('Yes') : t('No')) . '</td>', t('Verify required field.'), t('Ubercart'));
$this
->assertRaw('<td align="center">' . $edit['ordering'] . '</td>', t('Verify ordering field.'), t('Ubercart'));
$types = _uc_attribute_display_types();
$this
->assertRaw('<td>' . $types[$edit['display']] . '</td>', t('Verify display field.'), t('Ubercart'));
$aid = db_result(db_query("SELECT aid FROM {uc_attributes} WHERE name = '%s'", $edit['name']));
$this
->assertTrue($aid, t('Attribute was created.'));
$attribute = uc_attribute_load($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 created properly.'), t('Ubercart'));
}