You are here

function MerciUserTestCase::_testMerciStaffModule in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2

Same name and namespace in other branches
  1. 6.2 tests/merci_user.test \MerciUserTestCase::_testMerciStaffModule()

File

tests/merci_user.test, line 73

Class

MerciUserTestCase

Code

function _testMerciStaffModule() {
  $this
    ->drupalLogin($this->admin_user);

  // Create a contenty type only staff can reserve.
  $bucketstaff = $this
    ->merciCreateItem('bucket', 'bucketstaff');

  // Create merci staff user.
  $staff_user = $this
    ->drupalCreateUser(array(
    'view revisions',
    'revert revisions',
    'create confirmed reservations',
    'edit own bucket content',
    'delete own bucket content',
    'edit own bucketstaff content',
    'delete own bucketstaff content',
    'edit own resource content',
    'delete own resource content',
    'create reservations',
    //'access devel information',
    'manage reservations',
    'administer nodes',
  ));
  $this
    ->drupalLogin($staff_user);
  $today = date('Y-m-d');

  // Create our first reservation for staff.  Should pass.
  $node = $bucketstaff;
  $edit = array(
    'title' => $this
      ->randomName(),
    'field_merci_date[und][0][value][date]' => $today,
    'field_merci_date[und][0][value][time]' => '09:15',
    'field_merci_date[und][0][value2][date]' => $today,
    'field_merci_date[und][0][value2][time]' => '11:15',
    'merci_reservation_items[choice_1][merci_item_nid]' => $node->type,
  );
  $first = $this
    ->merciCreateNode('merci-reservation', $edit);
  $this
    ->assertText(t("@title has been created", array(
    '@title' => $edit['title'],
  )));

  // Update reservation with merci user as author.  Should Fail.
  $edit = array(
    'name' => $this->merci_user->name,
  );
  $second = $this
    ->merciUpdateNode($first->nid, $edit);
  $name = node_get_types('name', $type);
  $this
    ->assertText(t("You do not have permission to reserve @title.", array(
    '@title' => $name,
  )));

  // Update reservation with merci user as author with override on.  Should Pass.
  $edit = array(
    'name' => $this->merci_user->name,
    'override' => 1,
  );
  $second = $this
    ->merciUpdateNode($first->nid, $edit);
  $this
    ->assertText(t("@title has been updated", array(
    '@title' => $second->title,
  )));

  // Update reservation status with merci user as author with override off.  Should Pass as status should be validated by the admin user.
  $edit = array(
    'name' => $this->merci_user->name,
    'merci_reservation_status' => 5,
  );
  $second = $this
    ->merciUpdateNode($first->nid, $edit);
  $this
    ->assertText(t("@title has been updated", array(
    '@title' => $second->title,
  )));
}