You are here

public function UbercartAttributeTestCase::testAttributeUIProductAttributes in Ubercart 7.3

Tests the "product attributes" page.

File

uc_attribute/tests/uc_attribute.test, line 642
Ubercart Attribute Tests.

Class

UbercartAttributeTestCase
SimpleTests for the Ubercart Attributes API.

Code

public function testAttributeUIProductAttributes() {
  $product = $this
    ->createProduct();
  $attribute = self::createAttribute(array(
    'display' => 1,
  ));
  $option = self::createAttributeOption(array(
    'aid' => $attribute->aid,
  ));
  $this
    ->drupalGet('node/' . $product->nid . '/edit/attributes');
  $this
    ->assertText('You must first add attributes to this product.');
  $this
    ->clickLink('Add an attribute');
  $this
    ->assertText($attribute->name);
  $this
    ->drupalPost(NULL, array(
    'add_attributes[' . $attribute->aid . ']' => 1,
  ), t('Add attributes'));
  $this
    ->assertText('1 attribute has been added.');
  $this
    ->assertText($attribute->name, 'Attribute name found');
  $this
    ->assertFieldByName('attributes[' . $attribute->aid . '][label]', $attribute->label, 'Attribute label found');
  $this
    ->assertText($option->name, 'Default option name found');
  $this
    ->assertText(uc_currency_format($option->price), 'Default option price found');
  $this
    ->assertFieldByName('attributes[' . $attribute->aid . '][display]', $attribute->display, 'Attribute display setting found');
  $this
    ->drupalGet('node/' . $product->nid . '/edit/attributes/add');
  $this
    ->assertNoText($attribute->name);
  $this
    ->assertText('No attributes left to add.');
  $edit = array(
    'attributes[' . $attribute->aid . '][remove]' => 1,
  );
  $this
    ->drupalPost('node/' . $product->nid . '/edit/attributes', $edit, t('Save changes'));
  $this
    ->assertText('You must first add attributes to this product.');
}