commerce_pricelist_role.test in Commerce Pricelist 7
Functional tests for the commerce pricelist role module.
File
commerce_pricelist_role/tests/commerce_pricelist_role.testView source
<?php
/**
* @file
* Functional tests for the commerce pricelist role module.
*/
/**
* Test price list features for a product display that only has one product attached.
*/
class CommercePricelistRoleTestCaseSimpleProduct extends CommercePricelistTestCase {
/**
* Implementation of getInfo().
*/
public static function getInfo() {
return array(
'name' => 'Commerce Pricelist Role',
'description' => 'Test assigning a pricelist to a specific role',
'group' => 'Commerce Pricelist',
);
}
/**
* Implementation of setUp().
*/
function setUp($other_modules = array()) {
parent::setUp(array(
'commerce_pricelist_role',
));
// Add pricelist item.
$this
->createDummyPricelistItem();
$this
->createDummyPricelistItem(array(
'price_amount' => 50,
'pricelist_id' => $this->pricelist_b->list_id,
));
}
/**
* Test if the price of a product changes when a price list is assigned a role.
*/
public function testCommercePricelistSetRole() {
// Log in as a admin.
$this
->drupalLogin($this->site_admin);
$admin_role = key($this->site_admin->roles);
$edit = array();
// Enable pricelist for admin.
$edit["commerce_pricelist_role[{$admin_role}]"] = TRUE;
// Disable for anonymous.
$edit['commerce_pricelist_role[1]'] = FALSE;
$edit_path = 'admin/commerce/pricelist/commerce_pricelist_list/' . $this->pricelist_b->list_id . '/edit';
// Submit pricelist form
$this
->drupalPost($edit_path, $edit, t('Save'));
$this
->assertText(t('Price list saved'), t('Saved pricelist B'));
// Go to product display page
$this
->drupalGet('node/' . $this->product_node->nid);
$this
->assertText('$0.50', t('Product price was correctly set from price list.'));
// Log out
$this
->drupalLogout();
// Go to product display page
$this
->drupalGet('node/' . $this->product_node->nid);
$this
->assertNoText('$0.50', t('Product price was correctly set from price list.'));
}
}
Classes
Name | Description |
---|---|
CommercePricelistRoleTestCaseSimpleProduct | Test price list features for a product display that only has one product attached. |