コード例 #1
0
 /**
  * @return DateRange
  */
 private function GetReservationDuration()
 {
     $startDate = $this->_page->GetStartDate();
     $startTime = $this->_page->GetStartTime();
     $endDate = $this->_page->GetEndDate();
     $endTime = $this->_page->GetEndTime();
     $timezone = $this->userSession->Timezone;
     return DateRange::Create($startDate . ' ' . $startTime, $endDate . ' ' . $endTime, $timezone);
 }
コード例 #2
0
 public function testCreationBuildsReservationFromPageData()
 {
     $timezone = $this->user->Timezone;
     $userId = $this->page->GetUserId();
     $resourceId = $this->page->GetResourceId();
     $title = $this->page->GetTitle();
     $description = $this->page->GetDescription();
     $startDate = $this->page->GetStartDate();
     $endDate = $this->page->GetEndDate();
     $startTime = $this->page->GetStartTime();
     $endTime = $this->page->GetEndTime();
     $additionalResources = $this->page->GetResources();
     $pageAccessories = $this->page->GetAccessories();
     $pageAttributes = $this->page->GetAttributes();
     $roFactory = new RepeatOptionsFactory();
     $repeatOptions = $roFactory->CreateFromComposite($this->page, $timezone);
     $participants = $this->page->GetParticipants();
     $invitees = $this->page->GetInvitees();
     $attachment = new FakeUploadedFile();
     $this->page->attachment = $attachment;
     $resource = new FakeBookableResource($resourceId, 'r1');
     $additionalResource1 = new FakeBookableResource($additionalResources[0], 'r2');
     $additionalResource2 = new FakeBookableResource($additionalResources[1], 'r3');
     $accessories = array();
     foreach ($pageAccessories as $pa) {
         $accessories[] = new ReservationAccessory($pa->Id, $pa->Quantity, $pa->Name);
     }
     $expectedAttributes = array();
     foreach ($pageAttributes as $attr) {
         $expectedAttributes[] = new AttributeValue($attr->Id, $attr->Value);
     }
     $startReminder = new ReservationReminder($this->page->GetStartReminderValue(), $this->page->GetStartReminderInterval());
     $endReminder = new ReservationReminder($this->page->GetEndReminderValue(), $this->page->GetEndReminderInterval());
     $this->resourceRepository->expects($this->at(0))->method('LoadById')->with($this->equalTo($resourceId))->will($this->returnValue($resource));
     $this->resourceRepository->expects($this->at(1))->method('LoadById')->with($this->equalTo($additionalResources[0]))->will($this->returnValue($additionalResource1));
     $this->resourceRepository->expects($this->at(2))->method('LoadById')->with($this->equalTo($additionalResources[1]))->will($this->returnValue($additionalResource2));
     $duration = DateRange::Create($startDate . ' ' . $startTime, $endDate . ' ' . $endTime, $timezone);
     $actualReservation = $this->presenter->BuildReservation();
     $this->assertEquals($userId, $actualReservation->UserId());
     $this->assertEquals($resourceId, $actualReservation->ResourceId());
     $this->assertEquals($title, $actualReservation->Title());
     $this->assertEquals($description, $actualReservation->Description());
     $this->assertEquals($duration, $actualReservation->CurrentInstance()->Duration());
     $this->assertEquals($repeatOptions, $actualReservation->RepeatOptions());
     $this->assertEquals($participants, $actualReservation->CurrentInstance()->AddedParticipants());
     $this->assertEquals($invitees, $actualReservation->CurrentInstance()->AddedInvitees());
     $this->assertEquals($accessories, $actualReservation->Accessories());
     $this->assertTrue(in_array($expectedAttributes[0], $actualReservation->AttributeValues()));
     $expectedAttachment = ReservationAttachment::Create($attachment->OriginalName(), $attachment->MimeType(), $attachment->Size(), $attachment->Contents(), $attachment->Extension(), 0);
     $this->assertEquals(array($expectedAttachment), $actualReservation->AddedAttachments());
     $this->assertEquals($startReminder, $actualReservation->GetStartReminder());
     $this->assertEquals($endReminder, $actualReservation->GetEndReminder());
 }