public function testSendsReservationDeletedEmails()
 {
     $ownerId = 828;
     $owner = new User();
     $participantId1 = 50;
     $participant1 = new User();
     $participantId2 = 60;
     $participant2 = new User();
     $instance1 = new TestReservation();
     $instance1->WithAddedParticipants(array(1000, 2000));
     $instance1->WithExistingParticipants(array($participantId1, $participantId2));
     $series = new TestReservationSeries();
     $series->WithOwnerId($ownerId);
     $series->WithCurrentInstance($instance1);
     $userRepo = $this->getMock('IUserRepository');
     $attributeRepo = $this->getMock('IAttributeRepository');
     $userRepo->expects($this->at(0))->method('LoadById')->with($this->equalTo($ownerId))->will($this->returnValue($owner));
     $userRepo->expects($this->at(1))->method('LoadById')->with($this->equalTo($participantId1))->will($this->returnValue($participant1));
     $userRepo->expects($this->at(2))->method('LoadById')->with($this->equalTo($participantId2))->will($this->returnValue($participant2));
     $notification = new ParticipantDeletedEmailNotification($userRepo, $attributeRepo);
     $notification->Notify($series);
     $this->assertEquals(2, count($this->fakeEmailService->_Messages));
     $lastExpectedMessage = new ParticipantAddedEmail($owner, $participant2, $series, $attributeRepo);
     $this->assertInstanceOf('ParticipantDeletedEmail', $this->fakeEmailService->_LastMessage);
     //		$this->assertEquals($lastExpectedMessage, $this->fakeEmailService->_LastMessage);
 }
 public function testWhenBothResourcesAreOverLimit()
 {
     $series = new TestReservationSeries();
     $series->WithCurrentInstance(new TestReservation());
     $series->WithResource($this->resourceLimit10);
     $series->AddResource($this->resourceLimit20);
     $series->ChangeParticipants(range(1, 22));
     $result = $this->rule->Validate($series);
     $this->assertFalse($result->IsValid());
 }
 public function testRuleIsInValidIfReservationCrossesDayInScheduleTimezone()
 {
     $start = Date::Now();
     $end = Date::Now()->AddDays(1);
     $reservation = new TestReservationSeries();
     $reservation->WithCurrentInstance(new TestReservation('1', new DateRange($start, $end)));
     $resource = new FakeBookableResource(1);
     $resource->SetAllowMultiday(true);
     $resource2 = new FakeBookableResource(2);
     $resource2->SetAllowMultiday(false);
     $reservation->WithResource($resource);
     $reservation->AddResource($resource2);
     $this->scheduleRepository->expects($this->once())->method('LoadById')->with($this->equalTo($reservation->ScheduleId()))->will($this->returnValue($this->schedule));
     $rule = new ResourceCrossDayRule($this->scheduleRepository);
     $result = $rule->Validate($reservation);
     $this->assertFalse($result->IsValid());
 }
 public function testWhenNotConstrainedByTime()
 {
     $this->fakeConfig->SetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_START_TIME_CONSTRAINT, ReservationStartTimeConstraint::NONE);
     $now = Date::Parse('2011-04-04 12:13:15', 'UTC');
     Date::_SetNow($now);
     $start = Date::Parse('2011-04-04 12:13:14', 'UTC');
     $end = $start->AddDays(5);
     $reservation = new TestReservationSeries();
     $reservation->WithCurrentInstance(new TestReservation('1', new DateRange($start, $end)));
     $rule = new ReservationStartTimeRule($this->scheduleRepository);
     $result = $rule->Validate($reservation);
     $this->assertTrue($result->IsValid());
 }
 public function testHandlingReservationCreationDelegatesToHandler()
 {
     $series = new TestReservationSeries();
     $instance = new Reservation($series, NullDateRange::Instance());
     $series->WithCurrentInstance($instance);
     $this->handler->expects($this->once())->method('Handle')->with($this->equalTo($series), $this->isInstanceOf('FakeReservationSavePage'))->will($this->returnValue(true));
     $this->presenter->HandleReservation($series);
     $this->assertEquals($instance->ReferenceNumber(), $this->page->referenceNumber);
     $this->assertEquals($series->RequiresApproval(), $this->page->requiresApproval);
 }