From c506720689bf388cb976dc4f3268f138f44a93b4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 25 Apr 2022 07:47:47 +0200 Subject: [PATCH] Respect that interval is now always set within timeIntervals The property will always be set in the future. We no longer can use it as an indicator. We switch to freq as new indicator. We also ensure that start has to be given for a single date. Relates: #9892 --- .../DestinationDataImportService/DatesFactory.php | 6 +++++- .../DestinationDataTest/Fixtures/Response.json | 15 ++++++++++----- .../DatesFactoryTest.php | 15 +++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Classes/Service/DestinationDataImportService/DatesFactory.php b/Classes/Service/DestinationDataImportService/DatesFactory.php index d3cedd1..2eb42fb 100644 --- a/Classes/Service/DestinationDataImportService/DatesFactory.php +++ b/Classes/Service/DestinationDataImportService/DatesFactory.php @@ -45,7 +45,11 @@ class DatesFactory private function isDateSingleDate(array $date): bool { - return empty($date['interval']); + $frequency = $date['freq'] ?? ''; + $start = $date['start'] ?? ''; + + return $frequency === '' + && $start !== ''; } private function isDateInterval(array $date): bool diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json index 7928034..9c3534d 100644 --- a/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json @@ -90,7 +90,8 @@ "weekdays": [], "start": "2099-12-19T15:00:00+01:00", "end": "2099-12-19T16:30:00+01:00", - "tz": "Europe/Berlin" + "tz": "Europe/Berlin", + "interval": 1 } ], "kitchenTimeIntervals": [], @@ -256,7 +257,8 @@ "weekdays": [], "start": "2099-12-16T15:00:00+01:00", "end": "2099-12-16T16:30:00+01:00", - "tz": "Europe/Berlin" + "tz": "Europe/Berlin", + "interval": 1 }, { "weekdays": [], @@ -271,7 +273,8 @@ "weekdays": [], "start": "2099-02-17T15:00:00+01:00", "end": "2099-02-17T17:00:00+01:00", - "tz": "Europe/Berlin" + "tz": "Europe/Berlin", + "interval": 1 } ], "kitchenTimeIntervals": [], @@ -436,7 +439,8 @@ "weekdays": [], "start": "2099-12-01T19:00:00+01:00", "end": "2099-12-01T20:00:00+01:00", - "tz": "Europe/Berlin" + "tz": "Europe/Berlin", + "interval": 1 }, { "weekdays": [ @@ -454,7 +458,8 @@ "weekdays": [], "start": "2099-12-22T19:00:00+01:00", "end": "2099-12-22T20:00:00+01:00", - "tz": "Europe/Berlin" + "tz": "Europe/Berlin", + "interval": 1 } ], "kitchenTimeIntervals": [], diff --git a/Tests/Unit/Service/DestinationDataImportService/DatesFactoryTest.php b/Tests/Unit/Service/DestinationDataImportService/DatesFactoryTest.php index 6638627..bf3454f 100644 --- a/Tests/Unit/Service/DestinationDataImportService/DatesFactoryTest.php +++ b/Tests/Unit/Service/DestinationDataImportService/DatesFactoryTest.php @@ -46,18 +46,9 @@ class DatesFactoryTest extends TestCase 'Empty Intervals' => [ 'unkownInput' => [], ], - 'Intervals with interval no repeatUntil' => [ + 'Single interval without values' => [ 'unkownInput' => [ [ - 'interval' => 1, - ], - ], - ], - 'Intervals with interval and repeatUntil bu no freq' => [ - 'unkownInput' => [ - [ - 'interval' => 1, - 'repeatUntil' => 'something', ], ], ], @@ -75,6 +66,7 @@ class DatesFactoryTest extends TestCase 'start' => '2099-06-21T16:00:00+02:00', 'end' => '2099-06-21T22:00:00+02:00', 'tz' => 'Europe/Berlin', + 'interval' => 1, ]], false); self::assertInstanceOf(\Generator::class, $result); @@ -100,6 +92,7 @@ class DatesFactoryTest extends TestCase 'start' => '2099-06-21T16:00:00+02:00', 'end' => '2099-06-21T22:00:00+02:00', 'tz' => 'Europe/Berlin', + 'interval' => 1, ]], true); self::assertInstanceOf(\Generator::class, $result); @@ -258,6 +251,7 @@ class DatesFactoryTest extends TestCase 'start' => '2099-06-21T16:00:00+02:00', 'end' => '2099-06-21T22:00:00+02:00', 'tz' => 'Europe/Berlin', + 'interval' => 1, ], [ 'start' => '2099-04-01T16:00:00+02:00', @@ -304,6 +298,7 @@ class DatesFactoryTest extends TestCase 'start' => '2099-06-21T16:00:00+02:00', 'end' => '2099-06-21T22:00:00+02:00', 'tz' => 'Europe/Berlin', + 'interval' => 1, ], [ 'start' => '2099-04-01T16:00:00+02:00',