public function testNoConflictsIfReservationExistsAtSameTimeForDifferentResource() { $resourceId1 = 1; $resourceId2 = 2; $resourceId3 = 3; $currentId = 19; $currentDate = new DateRange(Date::Now()->AddDays(10), Date::Now()->AddDays(15)); $current = new TestReservation('ref', $currentDate); $current->SetReservationId($currentId); $series = new ExistingReservationSeries(); $series->WithPrimaryResource(new FakeBookableResource($resourceId1)); $series->WithResource(new FakeBookableResource($resourceId2)); $series->WithCurrentInstance($current); $reservations = array(new TestReservationItemView($currentId + 1, Date::Now(), Date::Now(), $resourceId3)); $this->strategy->expects($this->once())->method('GetItemsBetween')->with($this->anything(), $this->anything())->will($this->returnValue($reservations)); $rule = new ExistingResourceAvailabilityRule($this->strategy, $this->timezone); $ruleResult = $rule->Validate($series); $this->assertTrue($ruleResult->IsValid()); }
public function testRemovesParticipationFromAllInstances() { $userId = 1; $r1 = new TestReservation(); $r1->WithParticipant($userId); $r1->SetReservationId(100); $r2 = new TestReservation(); $r2->WithParticipant($userId); $r2->SetReservationId(101); $r3 = new TestReservation(); $r3->WithParticipant(89); $r3->SetReservationId(102); $builder = new ExistingReservationSeriesBuilder(); $builder->WithInstance($r1); $builder->WithInstance($r2); $builder->WithInstance($r3); $series = $builder->Build(); $series->CancelAllParticipation($userId); $events = $series->GetEvents(); $this->assertContains($userId, $r1->RemovedParticipants()); $this->assertContains($userId, $r2->RemovedParticipants()); $this->assertEmpty($r3->RemovedInvitees()); $this->assertTrue(in_array(new InstanceUpdatedEvent($r1, $series), $events)); $this->assertTrue(in_array(new InstanceUpdatedEvent($r2, $series), $events)); $this->assertFalse(in_array(new InstanceUpdatedEvent($r3, $series), $events)); }