public function UbercartRolesTestCase::testRoleAdminDelete in Ubercart 7.3
File
- uc_roles/tests/uc_roles.test, line 64
- Role assignment product feature tests.
Class
- UbercartRolesTestCase
- Tests the role purchase functionality.
Code
public function testRoleAdminDelete() {
$rid = $this
->drupalCreateRole(array(
'access content',
));
$this
->drupalLogin($this->adminUser);
$this
->drupalPost('node/' . $this->product->nid . '/edit/features', array(
'feature' => 'role',
), t('Add'));
$edit = array(
'uc_roles_role' => $rid,
'end_override' => TRUE,
'uc_roles_expire_relative_duration' => 1,
'uc_roles_expire_relative_granularity' => 'day',
);
$this
->drupalPost(NULL, $edit, t('Save feature'));
$this
->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
$order = $this
->checkout();
uc_payment_enter($order->order_id, 'other', $order->order_total);
$account = user_load($order->uid);
$this
->assertTrue(isset($account->roles[$rid]), 'Existing user was granted role.');
$this
->drupalGet('user/' . $order->uid . '/edit');
$this
->assertText('Ubercart roles', 'Ubercart roles fieldset found.');
$this
->assertNoText('There are no pending expirations for roles this user.', 'User has a role expiration.');
$this
->drupalPost('user/' . $order->uid . '/edit', array(
'roles[' . $rid . ']' => FALSE,
), t('Save'));
$account = user_load($order->uid, TRUE);
$this
->assertFalse(isset($account->roles[$rid]), 'Role was removed from user.');
$this
->assertText('There are no pending expirations for roles this user.', 'User has no role expirations.');
}