public function UbercartProductTestCase::testProductClassForm in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_product/uc_product.test \UbercartProductTestCase::testProductClassForm()
File
- uc_product/
tests/ uc_product.test, line 98 - Ubercart Product Tests
Class
- UbercartProductTestCase
- @file Ubercart Product Tests
Code
public function testProductClassForm() {
// Try making a new product class.
$class = $this
->randomName(12);
$type = strtolower($class);
$edit = array(
'pcid' => $class,
'name' => $class,
'description' => $this
->randomName(32),
);
$this
->drupalPost('admin/store/products/classes', $edit, t('Save'));
$this
->assertText(t('Product class saved.'), t('Product class form submitted.'));
$base = db_query('SELECT base FROM {node_type} WHERE type = :type', array(
':type' => $type,
))
->fetchField();
$this
->assertEqual($base, 'uc_product', t('The new content type has been created in the database.'));
// Change the machine name of an existing class.
$new_type = strtolower($this
->randomName(12));
$edit = array(
'type' => $new_type,
);
$this
->drupalPost('admin/structure/types/manage/' . $type, $edit, 'Save content type');
$this
->assertText('Machine name: ' . $new_type, 'Updated machine name found.');
$this
->assertNoText('Machine name: ' . $type, 'Old machine name not found.');
// Make an existing node type a product class.
$type = $this
->drupalCreateContentType();
$edit = array(
'pcid' => $type->type,
'name' => $type->name,
'description' => $type->description,
);
$node = $this
->drupalCreateNode(array(
'type' => $type->type,
));
$this
->drupalPost('admin/store/products/classes', $edit, t('Save'));
$this
->assertText(t('Product class saved.'), t('Product class form submitted.'));
$base = db_query('SELECT base FROM {node_type} WHERE type = :type', array(
':type' => $type->type,
))
->fetchField();
$this
->assertEqual($base, 'uc_product', t('The new content type has been taken over by uc_product.'));
$this
->drupalPost('node/' . $node->nid, array(
'qty' => '1',
), 'Add to cart');
$this
->assertText($node->title . ' added to your shopping cart.');
}