Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Calculate the next date using periodicity strategies.
Antonio Spinelli4e3c2ba72c33
diff --git a/app/Support/Calendar/Periodicity.php b/app/Support/Calendar/Periodicity.phpnew file mode 100644index 0000000000..05825e19a1--- /dev/null+++ b/app/Support/Calendar/Periodicity.php@@ -0,0 +1,33 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar;++enum Periodicity+{+ case Daily;+ case Weekly;+ case Fortnightly;+ case Monthly;+ case Quarterly;+ case HalfYearly;+ case Yearly;+}diff --git a/app/Support/Calendar/Periodicity/Daily.php b/app/Support/Calendar/Periodicity/Daily.phpnew file mode 100644index 0000000000..39fc34196d--- /dev/null+++ b/app/Support/Calendar/Periodicity/Daily.php@@ -0,0 +1,32 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++use Carbon\Carbon;++final class Daily extends Interval+{+ public function nextDate(Carbon $date, int $interval = 1): Carbon+ {+ return ($date->clone())->addDays($this->skip($interval));+ }+}diff --git a/app/Support/Calendar/Periodicity/Fortnightly.php b/app/Support/Calendar/Periodicity/Fortnightly.phpnew file mode 100644index 0000000000..a64880a058--- /dev/null+++ b/app/Support/Calendar/Periodicity/Fortnightly.php@@ -0,0 +1,27 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++final class Fortnightly extends Weekly+{+ const INTERVAL = 2;+}diff --git a/app/Support/Calendar/Periodicity/HalfYearly.php b/app/Support/Calendar/Periodicity/HalfYearly.phpnew file mode 100644index 0000000000..e8d6242bb2--- /dev/null+++ b/app/Support/Calendar/Periodicity/HalfYearly.php@@ -0,0 +1,27 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++final class HalfYearly extends Monthly+{+ const INTERVAL = 6;+}diff --git a/app/Support/Calendar/Periodicity/Interspacable.php b/app/Support/Calendar/Periodicity/Interspacable.phpnew file mode 100644index 0000000000..a10658cdfc--- /dev/null+++ b/app/Support/Calendar/Periodicity/Interspacable.php@@ -0,0 +1,29 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++use Carbon\Carbon;++interface Interspacable+{+ public function nextDate(Carbon $date, int $interval = 1): Carbon;+}diff --git a/app/Support/Calendar/Periodicity/Interval.php b/app/Support/Calendar/Periodicity/Interval.phpnew file mode 100644index 0000000000..73db1f0409--- /dev/null+++ b/app/Support/Calendar/Periodicity/Interval.php@@ -0,0 +1,32 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++abstract class Interval implements Interspacable+{+ const INTERVAL = 1;++ public function skip(int $skip): int+ {+ return static::INTERVAL * $skip;+ }+}diff --git a/app/Support/Calendar/Periodicity/Monthly.php b/app/Support/Calendar/Periodicity/Monthly.phpnew file mode 100644index 0000000000..34cc9bf3e6--- /dev/null+++ b/app/Support/Calendar/Periodicity/Monthly.php@@ -0,0 +1,32 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++use Carbon\Carbon;++class Monthly extends Interval+{+ public function nextDate(Carbon $date, int $interval = 1): Carbon+ {+ return ($date->clone())->addMonthsNoOverflow($this->skip($interval));+ }+}diff --git a/app/Support/Calendar/Periodicity/Quarterly.php b/app/Support/Calendar/Periodicity/Quarterly.phpnew file mode 100644index 0000000000..b20dc60250--- /dev/null+++ b/app/Support/Calendar/Periodicity/Quarterly.php@@ -0,0 +1,27 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++final class Quarterly extends Monthly+{+ const INTERVAL = 3;+}diff --git a/app/Support/Calendar/Periodicity/Weekly.php b/app/Support/Calendar/Periodicity/Weekly.phpnew file mode 100644index 0000000000..519ea143d8--- /dev/null+++ b/app/Support/Calendar/Periodicity/Weekly.php@@ -0,0 +1,32 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++use Carbon\Carbon;++class Weekly extends Interval+{+ public function nextDate(Carbon $date, int $interval = 1): Carbon+ {+ return ($date->clone())->addWeeks($this->skip($interval));+ }+}diff --git a/app/Support/Calendar/Periodicity/Yearly.php b/app/Support/Calendar/Periodicity/Yearly.phpnew file mode 100644index 0000000000..768f3d87b3--- /dev/null+++ b/app/Support/Calendar/Periodicity/Yearly.php@@ -0,0 +1,32 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Support\Calendar\Periodicity;++use Carbon\Carbon;++final class Yearly extends Interval+{+ public function nextDate(Carbon $date, int $interval = 1): Carbon+ {+ return ($date->clone())->addYearsNoOverflow($this->skip($interval));+ }+}diff --git a/tests/Support/Calendar/Periodicity/DailyTest.php b/tests/Support/Calendar/Periodicity/DailyTest.phpnew file mode 100644index 0000000000..b4f25f2e5e--- /dev/null+++ b/tests/Support/Calendar/Periodicity/DailyTest.php@@ -0,0 +1,42 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class DailyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Daily();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::tomorrow()),+ new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-01')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/FortnightlyTest.php b/tests/Support/Calendar/Periodicity/FortnightlyTest.phpnew file mode 100644index 0000000000..e28b818e92--- /dev/null+++ b/tests/Support/Calendar/Periodicity/FortnightlyTest.php@@ -0,0 +1,42 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class FortnightlyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Fortnightly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addWeeks(2)),+ new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-14')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/HalfYearlyTest.php b/tests/Support/Calendar/Periodicity/HalfYearlyTest.phpnew file mode 100644index 0000000000..08da7027c7--- /dev/null+++ b/tests/Support/Calendar/Periodicity/HalfYearlyTest.php@@ -0,0 +1,50 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class HalfYearlyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\HalfYearly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)),+ new IntervalProvider(Carbon::parse('2019-01-29'), Carbon::parse('2019-07-29')),+ new IntervalProvider(Carbon::parse('2019-01-30'), Carbon::parse('2019-07-30')),+ new IntervalProvider(Carbon::parse('2019-01-31'), Carbon::parse('2019-07-31')),+ new IntervalProvider(Carbon::parse('2018-11-01'), Carbon::parse('2019-05-01')),+ new IntervalProvider(Carbon::parse('2019-08-29'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2019-08-30'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2019-08-31'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2021-02-28')),+ new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2021-02-28')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/IntervalProvider.php b/tests/Support/Calendar/Periodicity/IntervalProvider.phpnew file mode 100644index 0000000000..4725885d26--- /dev/null+++ b/tests/Support/Calendar/Periodicity/IntervalProvider.php@@ -0,0 +1,38 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;++readonly class IntervalProvider+{+ public Carbon $epoch;+ public Carbon $expected;+ public string $label;++ public function __construct(Carbon $epoch, Carbon $expected)+ {+ $this->epoch = $epoch;+ $this->expected = $expected;+ $this->label = "given {$epoch->toDateString()} expects {$expected->toDateString()}";+ }+}diff --git a/tests/Support/Calendar/Periodicity/IntervalTestCase.php b/tests/Support/Calendar/Periodicity/IntervalTestCase.phpnew file mode 100644index 0000000000..d5db1d901e--- /dev/null+++ b/tests/Support/Calendar/Periodicity/IntervalTestCase.php@@ -0,0 +1,52 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use FireflyIII\Support\Calendar\Periodicity\Interval;+use Tests\TestCase;++abstract class IntervalTestCase extends TestCase+{+ abstract public static function factory(): Interval;++ public abstract static function provideIntervals(): array;++ public static function provider(): \Generator+ {+ $intervals = static::provideIntervals();+ /** @var IntervalProvider $interval */+ foreach ($intervals as $interval) {+ yield "{$interval->label}" => [$interval];+ }+ }++ /**+ * @dataProvider provider+ * @param IntervalProvider $provider+ * @return void+ */+ public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void+ {+ $period = static::factory()->nextDate($provider->epoch);+ $this->assertEquals($provider->expected->toDateString(), $period->toDateString());+ }+}diff --git a/tests/Support/Calendar/Periodicity/MonthlyTest.php b/tests/Support/Calendar/Periodicity/MonthlyTest.phpnew file mode 100644index 0000000000..fab8785a4a--- /dev/null+++ b/tests/Support/Calendar/Periodicity/MonthlyTest.php@@ -0,0 +1,52 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class MonthlyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Monthly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addMonth(1)),+ new IntervalProvider(Carbon::parse('2019-01-01'), Carbon::parse('2019-02-01')),+ new IntervalProvider(Carbon::parse('2020-01-29'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2020-01-30'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2020-01-31'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2021-01-29'), Carbon::parse('2021-02-28')),+ new IntervalProvider(Carbon::parse('2021-01-30'), Carbon::parse('2021-02-28')),+ new IntervalProvider(Carbon::parse('2021-01-31'), Carbon::parse('2021-02-28')),+ new IntervalProvider(Carbon::parse('2023-03-31'), Carbon::parse('2023-04-30')),+ new IntervalProvider(Carbon::parse('2023-05-31'), Carbon::parse('2023-06-30')),+ new IntervalProvider(Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')),+ new IntervalProvider(Carbon::parse('2023-10-31'), Carbon::parse('2023-11-30')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/QuarterlyTest.php b/tests/Support/Calendar/Periodicity/QuarterlyTest.phpnew file mode 100644index 0000000000..22a527e109--- /dev/null+++ b/tests/Support/Calendar/Periodicity/QuarterlyTest.php@@ -0,0 +1,49 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class QuarterlyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Quarterly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addMonths(3)),+ new IntervalProvider(Carbon::parse('2019-01-29'), Carbon::parse('2019-04-29')),+ new IntervalProvider(Carbon::parse('2019-01-30'), Carbon::parse('2019-04-30')),+ new IntervalProvider(Carbon::parse('2019-01-31'), Carbon::parse('2019-04-30')),+ new IntervalProvider(Carbon::parse('2018-11-01'), Carbon::parse('2019-02-01')),+ new IntervalProvider(Carbon::parse('2019-11-29'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2019-11-30'), Carbon::parse('2020-02-29')),+ new IntervalProvider(Carbon::parse('2020-11-29'), Carbon::parse('2021-02-28')),+ new IntervalProvider(Carbon::parse('2020-11-30'), Carbon::parse('2021-02-28')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/WeeklyTest.php b/tests/Support/Calendar/Periodicity/WeeklyTest.phpnew file mode 100644index 0000000000..b889e977cd--- /dev/null+++ b/tests/Support/Calendar/Periodicity/WeeklyTest.php@@ -0,0 +1,42 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class WeeklyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Weekly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addWeek()),+ new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-07')),+ ];+ }+}diff --git a/tests/Support/Calendar/Periodicity/YearlyTest.php b/tests/Support/Calendar/Periodicity/YearlyTest.phpnew file mode 100644index 0000000000..b7f143fd62--- /dev/null+++ b/tests/Support/Calendar/Periodicity/YearlyTest.php@@ -0,0 +1,43 @@+<?php++/**+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace Tests\Support\Calendar\Periodicity;++use Carbon\Carbon;+use FireflyIII\Support\Calendar\Periodicity;+use FireflyIII\Support\Calendar\Periodicity\Interval;++class YearlyTest extends IntervalTestCase+{+ public static function factory(): Interval+ {+ return new Periodicity\Yearly();+ }++ public static function provideIntervals(): array+ {+ return [+ new IntervalProvider(Carbon::now(), Carbon::now()->addYears(1)),+ new IntervalProvider(Carbon::parse('2019-01-29'), Carbon::parse('2020-01-29')),+ new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')),+ ];+ }+}