public function testCancellationNoShowInDormStillBookable()
 {
     self::createTestBooking("NoShowFemales", "FemalesInMixedDorm", array("M" => 0, "F" => 2, "X" => 0), 132, "10", null, array('09.04.2014', '10.04.2014'), array());
     // $resourceProps
     // verify derived room type for the given dates
     $resourceIdDateRoomToRoomType = AllocationDBO::getDerivedRoomTypesForDates(DateTime::createFromFormat('!d.m.Y', "09.04.2014"), DateTime::createFromFormat('!d.m.Y', "10.04.2014"));
     $this->assertEquals("X", $resourceIdDateRoomToRoomType[132]["09.04.2014"], "mixed for 09.04.2014");
     $this->assertEquals("FX", $resourceIdDateRoomToRoomType[132]["10.04.2014"], "female/mixed for 10.04.2014");
     $freeBedIds = AllocationDBO::fetchAvailableBeds(132, 1, "X", array('09.04.2014', '10.04.2014'), array(), array());
     // $resourceProps
     $this->assertEquals(6, sizeof($freeBedIds), "Expecting 6 free beds in Snow White room");
     // find the booking that was just created
     $bookingSummaryArr = BookingDBO::getBookingsForDateRange(DateTime::createFromFormat('!d.m.Y', '09.04.2014'), DateTime::createFromFormat('!d.m.Y', '09.04.2014'), 'checkin', null, null, 'FemalesInMixedDorm');
     $this->assertEquals(1, sizeof($bookingSummaryArr), "Expecting 1 booking created");
     // verify booking summary query brings back the saved values
     $bookingSummary = array_shift(array_values($bookingSummaryArr));
     // load existing booking
     $booking = new AddBooking();
     $booking->load($bookingSummary->id);
     $allocationArr = $this->queryByXPath('/editbooking/allocations/allocation[name="NoShowFemales-1"]', $booking->toXml());
     $this->assertEquals(1, sizeof($allocationArr), "expecting 1 allocation with name 'NoShowFemales-1'");
     $allocation = array_shift($allocationArr);
     // toggle until cancelled
     $rowid = (string) $allocation->rowid;
     $booking->toggleBookingStateAt($rowid, "09.04.2014");
     $booking->toggleBookingStateAt($rowid, "09.04.2014");
     $booking->toggleBookingStateAt($rowid, "09.04.2014");
     $state = $booking->toggleBookingStateAt($rowid, "09.04.2014");
     $this->assertEquals("cancelled", $state, "expecting state on 09.04.2014 to be 'cancelled'");
     $booking->toggleBookingStateAt($rowid, "10.04.2014");
     $booking->toggleBookingStateAt($rowid, "10.04.2014");
     $booking->toggleBookingStateAt($rowid, "10.04.2014");
     $state = $booking->toggleBookingStateAt($rowid, "10.04.2014");
     $this->assertEquals("cancelled", $state, "expecting state on 10.04.2014 to be 'cancelled'");
     $booking->save();
     // i should be able to fit 9 more people on the 10/11 of April
     self::createTestBooking("FillUpTheRoom", "WithMaxOccupants", array("M" => 5, "F" => 4, "X" => 0), 132, "10", null, array('10.04.2014', '11.04.2014'), array());
     // $resourceProps
     // verify derived room type for the given dates
     $resourceIdDateRoomToRoomType = AllocationDBO::getDerivedRoomTypesForDates(DateTime::createFromFormat('!d.m.Y', "10.04.2014"), DateTime::createFromFormat('!d.m.Y', "11.04.2014"));
     $this->assertEquals("X", $resourceIdDateRoomToRoomType[132]["10.04.2014"], "mixed for 10.04.2014");
     $this->assertEquals("X", $resourceIdDateRoomToRoomType[132]["11.04.2014"], "mixed for 11.04.2014");
 }