From abbeca3e06c96c089bc3a9c8168648d6cdd5e5cf Mon Sep 17 00:00:00 2001 From: Greg Sarjeant <1686767+gsarjeant@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:27:55 -0400 Subject: [PATCH] Add first unit test. --- .gitignore | 11 ++++++++--- tests/Framework/Util/UtilTest.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/Framework/Util/UtilTest.php diff --git a/.gitignore b/.gitignore index de7aa0b..e13d4a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,15 @@ .vscode .DS_Store +# PHP Unit tests +phpunit +.phpunit.result.cache + +# Filesystem storage items *.sqlite *.txt - -/docker-compose.yml -init_complete storage/upload/css + +# Testing stuff +/docker-compose.yml scratch \ No newline at end of file diff --git a/tests/Framework/Util/UtilTest.php b/tests/Framework/Util/UtilTest.php new file mode 100644 index 0000000..7f0d248 --- /dev/null +++ b/tests/Framework/Util/UtilTest.php @@ -0,0 +1,31 @@ +modify('-1 minute')->format('c'); + $relativeTime = Util::relative_time($oneMinuteAgo); + $this->assertSame($relativeTime, "1 minute ago"); + + $twoHoursAgo = $datetime->modify('-2 hours')->format('c'); + $relativeTime = Util::relative_time($twoHoursAgo); + $this->assertSame($relativeTime, "2 hours ago"); + + $threeDaysAgo = $datetime->modify('-3 days')->format('c'); + $relativeTime = Util::relative_time($threeDaysAgo); + $this->assertSame($relativeTime, "3 days ago"); + + $fourMonthsAgo = $datetime->modify('-4 months')->format('c'); + $relativeTime = Util::relative_time($fourMonthsAgo); + $this->assertSame($relativeTime, "4 months ago"); + + $fiveYearsAgo = $datetime->modify('-5 years')->format('c'); + $relativeTime = Util::relative_time($fiveYearsAgo); + $this->assertSame($relativeTime, "5 years ago"); + + } +} \ No newline at end of file