Exemplo n.º 1
0
 /**
  * DaysOfWeeks constructor.
  * @param Period $periode
  * @param GestyScheduler $scheduler
  */
 public function __construct(Period $periode, GestyScheduler $scheduler)
 {
     $this->periode = $periode;
     foreach ($this->periode->getDayIterator() as $currentDay) {
         $d = new Day($currentDay);
         if (!$scheduler->isDayOff($currentDay, ActivityType::TAP)) {
             $this->list_jours_tap[$d->getWeekDay()][] = $currentDay->format('Y-m-d');
         }
         if (!$scheduler->isDayOff($currentDay, ActivityType::GARDERIE_MORNING)) {
             $this->list_jours_garderie[$d->getWeekDay() . '-1'][] = $currentDay->format('Y-m-d');
         }
         if (!$scheduler->isDayOff($currentDay, ActivityType::GARDERIE_EVENING)) {
             $this->list_jours_garderie[$d->getWeekDay() . '-2'][] = $currentDay->format('Y-m-d');
         }
     }
 }
 /**
  * @dataProvider provideDates
  *
  * @param $date
  * @param $activityType
  * @param $isDayOffExpected
  */
 public function testShouldDatesAvailabilityBeCorrect($date, $activityType, $isDayAvailable)
 {
     $dateTime = new \DateTime($date);
     $strs = [ActivityType::CANTEEN => 'canteen', ActivityType::TAP => 'TAP', ActivityType::GARDERIE_MORNING => 'garderie morning', ActivityType::GARDERIE_EVENING => 'garderie evening'];
     $strAssert = $dateTime->format('D') . " " . $date . " for " . $strs[$activityType] . ($isDayAvailable ? " should be day available" : " should be day off");
     $this->assertEquals($isDayAvailable, !self::$gestyScheduler->isDayOff($dateTime, $activityType), $strAssert);
 }