Commit b648a748 authored by Laurent's avatar Laurent
Browse files

hotline #66376 display overlapsed openings 30 days before validity start

parent 51561674
- ticket #66376 : Les dates d'ouvertures exceptionnelles s'affichent 30 jours avant la date de début, même si des périodes de validité se superposent
\ No newline at end of file
......@@ -236,6 +236,17 @@ class Class_Ouverture extends Storm_Model_Abstract {
}
public function isValidDuring($from, $to) {
if ($this->isValidOnDate($from) || $this->isValidOnDate($to))
return true;
$time_start = strtotime($this->getValidityStart());
$time_end = strtotime($this->getValidityEnd());
return ($from <= $time_start && $time_end <= $to);
}
public function isExceptionalOpenOnDate($date) {
return $this->isExceptional()
&& (!$this->isClosure())
......
......@@ -118,8 +118,7 @@ class Class_Ouverture_Visitor {
return $now <= $opening_day && $now_plus_30 >= $opening_day;
}
return $opening->isValidOnDate($now)
|| $opening->isValidOnDate($now_plus_30);
return $opening->isValidDuring($now, $now_plus_30);
}
......
......@@ -71,12 +71,9 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
protected function _renderPeriods($periodical) {
if (!$periodical)
return '';
return ($periodical)
? $this->_renderPeriod(current($periodical))
: '';
return implode('',
array_map([$this, '_renderPeriod'],
$periodical));
}
......
......@@ -409,6 +409,25 @@ class BibControllerBibViewAnnecyTest extends BibControllerBibViewTestCase {
'id_site' => 4,
'jour_semaine' => Class_Ouverture::LUNDI]);
$this->fixture('Class_Ouverture',
['id' => 20,
'id_site' => 4,
'jour_semaine' => Class_Ouverture::MARDI]);
$this->fixture('Class_Ouverture',
['id' => 21,
'id_site' => 4,
'label' => 'Horaires réduits',
'jour_semaine' => Class_Ouverture::MARDI,
'debut_matin' => '00:00',
'fin_matin' => '00:00',
'debut_apres_midi' => '15:00',
'fin_apres_midi' => '17:00',
'validity_start' => '2016-07-01',
'validity_end' => '2016-07-20']);
$this->fixture('Class_Ouverture',
['id' => 2,
'id_site' => 4,
......@@ -536,9 +555,16 @@ class BibControllerBibViewAnnecyTest extends BibControllerBibViewTestCase {
/** @test */
public function openingsShouldNotContainsSecondPeriodLabel() {
$this->assertNotXPathContentContains('//div[contains(@class, "library_schedule")]//h3',
'du samedi 02 au dimanche 03 juillet 2016');
public function openingsShouldContainsSecondPeriodLabel() {
$this->assertXPathContentContains('//div[contains(@class, "library_schedule")]//h3',
'du samedi 02 au dimanche 03 juillet 2016');
}
/** @test */
public function openingsShouldContainsHorairesReduits() {
$this->assertXPathContentContains('//div[contains(@class, "library_schedule")]//h3',
'Horaires réduits du vendredi 01 au mercredi 20 juillet 2016');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment