/**
  * @param SchoolYear $schoolYear
  */
 private function addEventWithin(Period $event, SchoolYear $schoolYear)
 {
     if ($event->getFirstDate() > $schoolYear->getDateStart() && $event->getLastDate() < $schoolYear->getDateEnd()) {
         $holiday = new SchoolHoliday();
         $holiday->setDateStart($event->getFirstDate());
         $holiday->setDateEnd($event->getLastDate());
         $holiday->setDescription($event->getDescription());
         $holiday->setSchoolYear($schoolYear);
         $schoolYear->addSchoolHoliday($holiday);
         $this->getEntityManager()->persist($holiday);
     }
 }
 /**
  * Ensure arbitrary periods are correctly read.
  *
  * @dataProvider providerPeriods
  * @param string $startingDate
  * @param string $endingDate
  * @param string $desc
  * @param integer $indexInCalendar
  *
  * @uses \Scheduler\Component\FileReader\ICalendarFileReader
  * @uses \Scheduler\Component\DateContainer\Period
  */
 public function testShouldHaveCorrectPeriod($startingDate, $endingDate, $desc, $indexInCalendar)
 {
     $expected = new Period(new \DateTime($startingDate), new \DateTime($endingDate), $desc);
     $event = self::$events[$indexInCalendar];
     $this->assertEquals($expected->getFirstDate(), $event->getFirstDate(), "Starting date");
     $this->assertEquals($expected->getLastDate(), $event->getLastDate(), "End date");
     $this->assertEquals($expected->getDescription(), $event->getDescription(), "Description");
 }
Ejemplo n.º 3
0
 /**
  * @covers ::getFirstDate
  */
 public function testGetFirstDateIsSameDateEntered()
 {
     $this->assertEquals(new \DateTimeImmutable('2015-09-01'), self::$period->getFirstDate());
 }
 /**
  * Return all "garderies" registered for a given pupil and period.
  *
  * @param Eleve $eleve
  * @param Period $periode
  * @param boolean $subscribed_by_parent_only
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function findAllGarderiesForPeriode(Eleve $eleve, Period $periode, $subscribed_by_parent_only)
 {
     $em = $this->getEntityManager();
     $query = $em->createQueryBuilder()->select('t')->from('WCSCantineBundle:Garderie', 't')->where('t.eleve = :eleve')->andWhere('t.date >= :dateDebut')->andWhere('t.date <= :dateFin')->orderBy('t.date', 'ASC');
     if ($subscribed_by_parent_only) {
         $query->andWhere('t.subscribed_by_parent = TRUE');
     }
     $query->setParameter(':eleve', $eleve)->setParameter(':dateDebut', $periode->getFirstDate())->setParameter(':dateFin', $periode->getLastDate());
     return $query->getQuery()->getResult();
 }