Exemple #1
0
 public function testDateRangeReturnsAllDatesForRangeWithoutTime()
 {
     $begin = Date::Create(2008, 9, 9, 10, 11, 12, 'UTC');
     $end = Date::Create(2008, 9, 12, 10, 11, 12, 'UTC');
     $range = new DateRange($begin, $end);
     $expected[] = $begin->GetDate();
     $expected[] = $begin->AddDays(1)->GetDate();
     $expected[] = $begin->AddDays(2)->GetDate();
     $expected[] = $begin->AddDays(3)->GetDate();
     $actual = $range->Dates();
     //		foreach ($expected as $d)
     //		{
     //			echo $d->ToString();
     //			echo "\n";
     //		}
     //
     //		echo "\n";
     //
     //		foreach ($actual as $d)
     //		{
     //			echo $d->ToString();
     //			echo "\n";
     //		}
     //		$this->assertEquals($expected, $actual);
     $this->assertEquals(count($expected), count($actual));
     $this->assertTrue($expected[0]->Equals($actual[0]), "Dates[0] are not equal");
     $this->assertTrue($expected[1]->Equals($actual[1]), "Dates[1] are not equal");
     $this->assertTrue($expected[2]->Equals($actual[2]), "Dates[2] are not equal");
     $this->assertTrue($expected[3]->Equals($actual[3]), "Dates[3] are not equal");
 }
 /**
  * @param IRestServer $server
  * @param int $scheduleId
  * @param IDailyLayout $dailyLayout
  * @param DateRange $dates
  * @param ResourceDto[] $resources
  * @param IPrivacyFilter $privacyFilter
  */
 public function __construct(IRestServer $server, $scheduleId, IDailyLayout $dailyLayout, DateRange $dates, $resources, IPrivacyFilter $privacyFilter)
 {
     $this->scheduleId = $scheduleId;
     $this->AddService($server, WebServices::GetSchedule, array(WebServiceParams::ScheduleId => $scheduleId));
     foreach ($dates->Dates() as $date) {
         $scheduleDate = new ScheduleSlotResponse($server, $date);
         foreach ($resources as $resource) {
             $scheduleResource = new ScheduleSlotResourceResponse($server, $resource, $privacyFilter);
             $slots = $dailyLayout->GetLayout($date, $resource->GetId());
             foreach ($slots as $slot) {
                 $scheduleResource->AddSlot($slot);
             }
             $scheduleDate->AddResource($scheduleResource);
         }
         $this->dates[] = $scheduleDate;
     }
 }