You are here

function MerciIssueTestCase::testIssue1103328 in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2

Same name and namespace in other branches
  1. 6.2 tests/merci_issues.test \MerciIssueTestCase::testIssue1103328()

File

tests/merci_issues.test, line 66

Class

MerciIssueTestCase

Code

function testIssue1103328() {

  // Login the merci user.
  $this
    ->drupalLogin($this->merci_user);

  // Test we can reserve our three bucket items all at the same time.
  // Test the fourth reservation at the same time will fail.
  // Create our first reservation
  $node = $this->bucket1;
  $edit = array(
    'title' => $this
      ->randomName(),
    'field_merci_date[und][0][value][date]' => '2011-03-25',
    'field_merci_date[und][0][value][time]' => '09:45',
    'field_merci_date[und][0][value2][date]' => '2011-03-25',
    'field_merci_date[und][0][value2][time]' => '10:45',
    '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'],
  )));

  // Assign an item to test issue #1103328
  // Login the admin user.
  $this
    ->drupalLogin($this->admin_user);

  // Cancel the last reservation.  This should Pass
  $node = $this->bucket2;
  $edit = array(
    'merci_reservation_items[1][merci_item_nid]' => $node->nid,
  );
  $title = $first->title;
  $first = $this
    ->merciUpdateNode($first->nid, $edit);
  $this
    ->assertText(t("@title has been updated.", array(
    '@title' => $title,
  )));

  // Login the merci user.
  $this
    ->drupalLogin($this->merci_user);

  // Create our second reservation
  $node = $this->bucket2;
  $edit = array(
    'title' => $this
      ->randomName(),
    'field_merci_date[und][0][value][date]' => '2011-03-25',
    'field_merci_date[und][0][value][time]' => '13:45',
    'field_merci_date[und][0][value2][date]' => '2011-03-25',
    'field_merci_date[und][0][value2][time]' => '15:45',
    'merci_reservation_items[choice_1][merci_item_nid]' => $node->type,
  );
  $second = $this
    ->merciCreateNode('merci-reservation', $edit);
  $this
    ->assertText(t("@title has been created", array(
    '@title' => $edit['title'],
  )));

  // Create our third reservation
  $node = $this->bucket1;
  $edit = array(
    'title' => $this
      ->randomName(),
    'field_merci_date[und][0][value][date]' => '2011-03-25',
    'field_merci_date[und][0][value][time]' => '10:15',
    'field_merci_date[und][0][value2][date]' => '2011-03-25',
    'field_merci_date[und][0][value2][time]' => '15:15',
    'merci_reservation_items[choice_1][merci_item_nid]' => $node->type,
  );
  $third = $this
    ->merciCreateNode('merci-reservation', $edit);
  $this
    ->assertText(t("@title has been created", array(
    '@title' => $edit['title'],
  )));
}