From 84d5d48efd994329ade6f34d365b280b44799775 Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Wed, 13 Aug 2025 13:12:48 -0500 Subject: [PATCH 1/3] Create Calendar Enums and Tests --- .gitignore | 1 + .idea/php-test-framework.xml | 1 + src/Objects/Calendar/DayOfWeek.php | 41 +++++++++++ src/Objects/Calendar/Month.php | 81 ++++++++++++++++++++++ tests/Unit/CalendarTests/DayOfWeekTest.php | 40 +++++++++++ tests/Unit/CalendarTests/MonthTest.php | 54 +++++++++++++++ 6 files changed, 218 insertions(+) create mode 100644 src/Objects/Calendar/DayOfWeek.php create mode 100644 src/Objects/Calendar/Month.php create mode 100644 tests/Unit/CalendarTests/DayOfWeekTest.php create mode 100644 tests/Unit/CalendarTests/MonthTest.php diff --git a/.gitignore b/.gitignore index 3a7fd12..e8cba22 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,4 @@ fabric.properties ######## MacOS ######## ################################## .DS_Store +/.idea/copilotDiffState.xml diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml index 24adfe8..b075b45 100644 --- a/.idea/php-test-framework.xml +++ b/.idea/php-test-framework.xml @@ -17,6 +17,7 @@ + diff --git a/src/Objects/Calendar/DayOfWeek.php b/src/Objects/Calendar/DayOfWeek.php new file mode 100644 index 0000000..080c07c --- /dev/null +++ b/src/Objects/Calendar/DayOfWeek.php @@ -0,0 +1,41 @@ +value) { + self::Sunday->value => 0, + self::Monday->value => 1, + self::Tuesday->value => 2, + self::Wednesday->value => 3, + self::Thursday->value => 4, + self::Friday->value => 5, + self::Saturday->value => 6, + }; + + if (!$zero) { + $int++; + } + + return $int; + } +} \ No newline at end of file diff --git a/src/Objects/Calendar/Month.php b/src/Objects/Calendar/Month.php new file mode 100644 index 0000000..a16020f --- /dev/null +++ b/src/Objects/Calendar/Month.php @@ -0,0 +1,81 @@ + 1, + self::February => 2, + self::March => 3, + self::April => 4, + self::May => 5, + self::June => 6, + self::July => 7, + self::August => 8, + self::September => 9, + self::October => 10, + self::November => 11, + self::December => 12, + }; + } + + public function next(): self + { + return match ($this) { + self::January => self::February, + self::February => self::March, + self::March => self::April, + self::April => self::May, + self::May => self::June, + self::June => self::July, + self::July => self::August, + self::August => self::September, + self::September => self::October, + self::October => self::November, + self::November => self::December, + self::December => self::January, + }; + } + + public function previous(): self + { + return match ($this) { + self::January => self::December, + self::February => self::January, + self::March => self::February, + self::April => self::March, + self::May => self::April, + self::June => self::May, + self::July => self::June, + self::August => self::July, + self::September => self::August, + self::October => self::September, + self::November => self::October, + self::December => self::November, + }; + } +} \ No newline at end of file diff --git a/tests/Unit/CalendarTests/DayOfWeekTest.php b/tests/Unit/CalendarTests/DayOfWeekTest.php new file mode 100644 index 0000000..d58d6d1 --- /dev/null +++ b/tests/Unit/CalendarTests/DayOfWeekTest.php @@ -0,0 +1,40 @@ +value)->toBe("sunday") + ->and(DayOfWeek::Monday->value)->toBe("monday") + ->and(DayOfWeek::Tuesday->value)->toBe("tuesday") + ->and(DayOfWeek::Wednesday->value)->toBe("wednesday") + ->and(DayOfWeek::Thursday->value)->toBe("thursday") + ->and(DayOfWeek::Friday->value)->toBe("friday") + ->and(DayOfWeek::Saturday->value)->toBe("saturday"); + }); + + test("DayOfWeek toInt returns correct zero-based values", function () { + expect(DayOfWeek::Sunday->toInt())->toBe(0) + ->and(DayOfWeek::Monday->toInt())->toBe(1) + ->and(DayOfWeek::Tuesday->toInt())->toBe(2) + ->and(DayOfWeek::Wednesday->toInt())->toBe(3) + ->and(DayOfWeek::Thursday->toInt())->toBe(4) + ->and(DayOfWeek::Friday->toInt())->toBe(5) + ->and(DayOfWeek::Saturday->toInt())->toBe(6); + }); + + test("DayOfWeek toInt returns correct one-based values", function () { + expect(DayOfWeek::Sunday->toInt(false))->toBe(1) + ->and(DayOfWeek::Monday->toInt(false))->toBe(2) + ->and(DayOfWeek::Tuesday->toInt(false))->toBe(3) + ->and(DayOfWeek::Wednesday->toInt(false))->toBe(4) + ->and(DayOfWeek::Thursday->toInt(false))->toBe(5) + ->and(DayOfWeek::Friday->toInt(false))->toBe(6) + ->and(DayOfWeek::Saturday->toInt(false))->toBe(7); + }); +}); + diff --git a/tests/Unit/CalendarTests/MonthTest.php b/tests/Unit/CalendarTests/MonthTest.php new file mode 100644 index 0000000..c746719 --- /dev/null +++ b/tests/Unit/CalendarTests/MonthTest.php @@ -0,0 +1,54 @@ +next())->toBe(Month::February) + ->and(Month::February->next())->toBe(Month::March) + ->and(Month::March->next())->toBe(Month::April) + ->and(Month::April->next())->toBe(Month::May) + ->and(Month::May->next())->toBe(Month::June) + ->and(Month::June->next())->toBe(Month::July) + ->and(Month::July->next())->toBe(Month::August) + ->and(Month::August->next())->toBe(Month::September) + ->and(Month::September->next())->toBe(Month::October) + ->and(Month::October->next())->toBe(Month::November) + ->and(Month::November->next())->toBe(Month::December) + ->and(Month::December->next())->toBe(Month::January); + }); + + it("previous() returns the correct previous month for each month", function () { + expect(Month::January->previous())->toBe(Month::December) + ->and(Month::February->previous())->toBe(Month::January) + ->and(Month::March->previous())->toBe(Month::February) + ->and(Month::April->previous())->toBe(Month::March) + ->and(Month::May->previous())->toBe(Month::April) + ->and(Month::June->previous())->toBe(Month::May) + ->and(Month::July->previous())->toBe(Month::June) + ->and(Month::August->previous())->toBe(Month::July) + ->and(Month::September->previous())->toBe(Month::August) + ->and(Month::October->previous())->toBe(Month::September) + ->and(Month::November->previous())->toBe(Month::October) + ->and(Month::December->previous())->toBe(Month::November); + }); + + it("toInt() returns the correct integer value for each month", function () { + expect(Month::January->toInt())->toBe(1) + ->and(Month::February->toInt())->toBe(2) + ->and(Month::March->toInt())->toBe(3) + ->and(Month::April->toInt())->toBe(4) + ->and(Month::May->toInt())->toBe(5) + ->and(Month::June->toInt())->toBe(6) + ->and(Month::July->toInt())->toBe(7) + ->and(Month::August->toInt())->toBe(8) + ->and(Month::September->toInt())->toBe(9) + ->and(Month::October->toInt())->toBe(10) + ->and(Month::November->toInt())->toBe(11) + ->and(Month::December->toInt())->toBe(12); + }); +}); From 5bd6cc77c40f19059dbdda4704d2f380099b29e3 Mon Sep 17 00:00:00 2001 From: EncoreBot Date: Wed, 13 Aug 2025 18:14:15 +0000 Subject: [PATCH 2/3] Dusting --- src/Objects/Calendar/DayOfWeek.php | 1 + src/Objects/Calendar/Month.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Objects/Calendar/DayOfWeek.php b/src/Objects/Calendar/DayOfWeek.php index 080c07c..99ab8b4 100644 --- a/src/Objects/Calendar/DayOfWeek.php +++ b/src/Objects/Calendar/DayOfWeek.php @@ -1,4 +1,5 @@ Date: Wed, 13 Aug 2025 18:14:15 +0000 Subject: [PATCH 3/3] Ignore Duster Commit in Git Blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 3412848..2367749 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -43,3 +43,4 @@ e224e927dabcd3046455985118ed424c43aba054 20e2de4b44af7511cb0eb6e6f71676253b4c2667 e85fae4f7290329ac9cfae159e19c1bb55062e4b 10daa978ac4beebdbc8e9dcc6fa07657001fd91e +5bd6cc77c40f19059dbdda4704d2f380099b29e3