Exemplo n.º 1
0
 public function testFindSpecialDateByDateTime()
 {
     $parser = new Parser();
     $date = \DateTime::createFromFormat('Y-m-d', '2000-01-01');
     $found = $parser->findSpecialDateByDateTime($date);
     $all = $parser->getAllDates($date->format('Y'));
     $foundNewYearsDay = false;
     $this->assertTrue(count($found) < count($all));
     foreach ($found as $item) {
         if ($item instanceof \Stefanius\SpecialDates\CommonDates\NewYearsDay) {
             $foundNewYearsDay = true;
         }
     }
     $this->assertTrue($foundNewYearsDay);
 }
 public function monthWithoutDomainYearAction(Request $request, $year, $dutchMonthName)
 {
     if (!array_key_exists($dutchMonthName, $this->months)) {
         return $this->redirect('/');
     }
     if (strlen($year) !== 4 || $year < 1500 || !is_numeric($year)) {
         return $this->redirect('/');
     }
     $domain = new Domain($request);
     $parser = new Parser();
     $dates = $parser->findSpecialDateByMonthNumber($year, $this->months[$dutchMonthName]);
     $page = $this->buildPage(['title' => 'Feestelijke dagen in ' . $year . ' - ' . $dutchMonthName, 'description' => $year . ' - ' . ucfirst($dutchMonthName) . ' bevat ' . count($dates) . ' bijzondere dagen! Naast ' . $dutchMonthName . ' hebben we ook de andere maanden in kaart gebracht voor ' . $year, 'request' => $request]);
     $page->setDomainYear($year);
     return $this->render('StefaniusNationalHolidayBundle:Default:bymonth.html.twig', ['dates' => $dates, 'page' => $page, 'domain' => $domain, 'dutchMonthName' => $dutchMonthName, 'monthNumber' => $this->months[$dutchMonthName], 'months' => array_keys($this->months)]);
 }