public function UbercartAttributeTestCase::testAttributeUIProductAttributeOverview in Ubercart 6.2
Tests the product node attribute user interface.
File
- uc_attribute/
uc_attribute.test, line 719 - Ubercart Attribute Tests
Class
- UbercartAttributeTestCase
- SimpleTests for the Ubercart Attributes API.
Code
public function testAttributeUIProductAttributeOverview() {
$class = $this
->createProductClass();
$attribute = self::createAttribute();
uc_attribute_subject_save($attribute, 'class', $class->pcid);
$product = $this
->createProduct(array(
'type' => $class->pcid,
));
// Check product has attribute added by default.
$loaded_attribute = uc_attribute_load($attribute->aid, $product->nid, 'product');
$this
->assertEqual($attribute->name, $loaded_attribute->name, t('Product attribute added by default.'), t('Ubercart'));
uc_attribute_subject_delete($attribute->aid, 'product', $product->nid);
$this
->drupalGet('node/' . $product->nid . '/edit/attributes/add');
$edit = array();
$edit['add_attributes[]'] = $attribute->aid;
$this
->drupalPost(NULL, $edit, t('Add attributes'));
$this
->assertText($attribute->name, t('Product attribute added.'), t('Ubercart'));
$edit = array();
$edit["attributes[{$attribute->aid}][remove]"] = TRUE;
$this
->drupalPost(NULL, $edit, t('Save changes'));
$this
->assertText(t('You must first add attributes to this product.'), t('Product attribute removed.'), t('Ubercart'));
$this
->drupalPost(NULL, array(), t('Reset to defaults'));
$this
->drupalPost(NULL, array(), t('Reset'));
$this
->assertText($attribute->name, t('Product attribute reset successfully.'), t('Ubercart'));
}