From 554c5ebb63938dbd87887ae1cdb848dd5e529111 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Tue, 10 Nov 2020 14:23:00 +0100 Subject: [PATCH] hotline #121319 Drive : fix opening search when all openings have validity start but no end --- VERSIONS_HOTLINE/121319 | 1 + library/Class/Ouverture.php | 6 ++-- .../DriveCheckOutBookingTest.php | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 VERSIONS_HOTLINE/121319 diff --git a/VERSIONS_HOTLINE/121319 b/VERSIONS_HOTLINE/121319 new file mode 100644 index 00000000000..e9f3a293d3a --- /dev/null +++ b/VERSIONS_HOTLINE/121319 @@ -0,0 +1 @@ + - ticket #121319 : Drive : correction de la prise de rendez-vous lorsque le drive ne commence que la semaine suivante \ No newline at end of file diff --git a/library/Class/Ouverture.php b/library/Class/Ouverture.php index c0984075a7f..8b5c81ff570 100644 --- a/library/Class/Ouverture.php +++ b/library/Class/Ouverture.php @@ -295,7 +295,9 @@ class Class_Ouverture extends Storm_Model_Abstract { public function isValidOnDate($time) { $time_start = strtotime($this->getValidityStart()); - $time_end = strtotime($this->getValidityEnd() . ' +1 day'); + $time_end = $this->getValidityEnd() + ? strtotime($this->getValidityEnd() . ' +1 day') + : 0; if (($time_start <= 0) && ($time_end <= 0)) return true; @@ -303,7 +305,7 @@ class Class_Ouverture extends Storm_Model_Abstract { if (($time_start > 0) && ($time_end > 0)) return ($time_start <= $time) && ($time_end >= $time); - if($time_end > 0) + if ($time_end > 0) return $time <= $time_end; return $time >= $time_start; diff --git a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php index cd9c28fad48..f05e4ddf5ae 100644 --- a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php +++ b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php @@ -340,6 +340,42 @@ class DriveCheckOutBookingPlanWithoutHoldCheckTest extends DriveCheckOutBookingT +class DriveCheckOutBookingPlanOnBibWithDriveStartingNextWeekTest extends DriveCheckOutBookingTestCase { + public function setUp() { + parent::setUp(); + CLass_AdminVar::set('DRIVE_DISABLE_HOLD_CHECK',1); + $this->fixture('Class_Bib', + ['id' => 5, + 'enable_drive' => 1, + 'libelle' => 'Superdrive', + 'ouvertures' => [ + Class_Ouverture::chaqueSamedi('10:00', '12:00', '12:00', '15:00') + ->setValidityStart('2020-11-17') + ->beDrive()] ]); + + $timesource = new TimeSourceForTest('2020-11-10 11:30'); + Class_DriveCheckout_Plan::setTimeSource($timesource); + Class_DriveCheckout::setTimeSource($timesource); + + $this->dispatch('/opac/drive-checkout/plan/id_bib/5'); + } + + + /** @test */ + public function selectedLibraryShouldContainsSuperdrive() { + $this->assertXPathContentContains('//div[contains(@class, "card-title")]', 'Superdrive'); + } + + + /** @test */ + public function pageShouldContainsLinkToChoose2020_11_21() { + $this->assertXPathContentContains('//a[contains(@href, "/checkout_date/2020-11-21")]', + 'sam. 21 nov'); + } +} + + + class DriveCheckOutBookingPlanWithFuturExistingTest extends DriveCheckOutBookingTestCase { public function setUp() { -- GitLab