public function testBindsCustomAttributesWithValues()
 {
     $val1 = 'v1';
     $val2 = 'v2';
     $reservationView = new ReservationView();
     $reservationView->AddAttribute(new AttributeValue(10, $val1));
     $reservationView->AddAttribute(new AttributeValue(20, $val2));
     $binder = new ReservationCustomAttributeValueBinder($this->attributeRepository, $reservationView);
     $attributes = array(new CustomAttribute(10, '1', CustomAttributeTypes::SINGLE_LINE_TEXTBOX, CustomAttributeCategory::RESERVATION, '', false, '', 1), new CustomAttribute(20, '2', CustomAttributeTypes::SINGLE_LINE_TEXTBOX, CustomAttributeCategory::RESERVATION, '', false, '', 2));
     $this->attributeRepository->expects($this->once())->method('GetByCategory')->with($this->equalTo(CustomAttributeCategory::RESERVATION))->will($this->returnValue($attributes));
     $this->initializer->expects($this->at(0))->method('AddAttribute')->with($this->equalTo($attributes[0]), $this->equalTo($val1));
     $this->initializer->expects($this->at(1))->method('AddAttribute')->with($this->equalTo($attributes[1]), $this->equalTo($val2));
     $binder->Bind($this->initializer);
 }
예제 #2
0
 public function Bind(IReservationComponentInitializer $initializer)
 {
     $this->page->SetAdditionalResources($this->reservationView->AdditionalResourceIds);
     $this->page->SetTitle($this->reservationView->Title);
     $this->page->SetDescription($this->reservationView->Description);
     $this->page->SetReferenceNumber($this->reservationView->ReferenceNumber);
     $this->page->SetReservationId($this->reservationView->ReservationId);
     $this->page->SetIsRecurring($this->reservationView->IsRecurring());
     $this->page->SetRepeatType($this->reservationView->RepeatType);
     $this->page->SetRepeatInterval($this->reservationView->RepeatInterval);
     $this->page->SetRepeatMonthlyType($this->reservationView->RepeatMonthlyType);
     if ($this->reservationView->RepeatTerminationDate != null) {
         $this->page->SetRepeatTerminationDate($this->reservationView->RepeatTerminationDate->ToTimezone($initializer->GetTimezone()));
     }
     $this->page->SetRepeatWeekdays($this->reservationView->RepeatWeekdays);
     $participants = $this->reservationView->Participants;
     $invitees = $this->reservationView->Invitees;
     $this->page->SetParticipants($participants);
     $this->page->SetInvitees($invitees);
     $this->page->SetAllowParticipantsToJoin($this->reservationView->AllowParticipation);
     $this->page->SetAccessories($this->reservationView->Accessories);
     $currentUser = $initializer->CurrentUser();
     $this->page->SetCurrentUserParticipating($this->IsCurrentUserParticipating($currentUser->UserId));
     $this->page->SetCurrentUserInvited($this->IsCurrentUserInvited($currentUser->UserId));
     $canBeEdited = $this->reservationAuthorization->CanEdit($this->reservationView, $currentUser);
     $this->page->SetIsEditable($canBeEdited);
     $this->page->SetIsApprovable($this->reservationAuthorization->CanApprove($this->reservationView, $currentUser));
     $this->page->SetAttachments($this->reservationView->Attachments);
     $showUser = $this->privacyFilter->CanViewUser($initializer->CurrentUser(), $this->reservationView);
     $showDetails = $this->privacyFilter->CanViewDetails($initializer->CurrentUser(), $this->reservationView);
     $initializer->ShowUserDetails($showUser);
     $initializer->ShowReservationDetails($showDetails);
     if (!empty($this->reservationView->StartReminder)) {
         $this->page->SetStartReminder($this->reservationView->StartReminder->GetValue(), $this->reservationView->StartReminder->GetInterval());
     }
     if (!empty($this->reservationView->EndReminder)) {
         $this->page->SetEndReminder($this->reservationView->EndReminder->GetValue(), $this->reservationView->EndReminder->GetInterval());
     }
 }