From d78dfa7e745924699adade5e254f911d7adf27e3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 21 Sep 2023 15:20:42 +0000 Subject: [PATCH] fix tests --- Module/ModuleAbstract.php | 2 +- Stdlib/Base/SmartDateTime.php | 5 ++++- tests/Stdlib/Base/SmartDateTimeTest.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index fd53ccb0c..7c3497761 100755 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -125,7 +125,7 @@ abstract class ModuleAbstract $this->app = $app ?? new class() extends ApplicationAbstract {}; if (self::$auditor === null && static::ID !== 1006200000) { - self::$auditor = $this->app->moduleManager?->get('Auditor', 'Api'); + self::$auditor = $this->app->moduleManager->get('Auditor', 'Api'); self::$auditor = self::$auditor === null || self::$auditor::ID === 0 ? null : self::$auditor; } } diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index 43f4a1e1a..e987e75a5 100755 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -114,7 +114,10 @@ class SmartDateTime extends \DateTime $yearChange = (int) \floor(((int) $this->format('m') - 1 + $m) / 12); $yearNew = (int) $this->format('Y') + $y + $yearChange; - $monthNew = ((int) $this->format('m') + $m - 1) % 12 + 1; + $monthNew = (int) $this->format('m') + $m; + $monthNew = $monthNew < 0 + ? 12 + ($monthNew - 1) % 12 + 1 + : ($monthNew - 1) % 12 + 1; $dayMonthOld = \cal_days_in_month($calendar, (int) $this->format('m'), (int) $this->format('Y')); $dayMonthNew = \cal_days_in_month($calendar, $monthNew, $yearNew); diff --git a/tests/Stdlib/Base/SmartDateTimeTest.php b/tests/Stdlib/Base/SmartDateTimeTest.php index 9657f4cb1..00e06bed3 100755 --- a/tests/Stdlib/Base/SmartDateTimeTest.php +++ b/tests/Stdlib/Base/SmartDateTimeTest.php @@ -16,6 +16,8 @@ namespace phpOMS\tests\Stdlib\Base; use phpOMS\Stdlib\Base\SmartDateTime; +require_once __DIR__ . '/../../Autoloader.php'; + /** * @testdox phpOMS\tests\Stdlib\Base\SmartDateTimeTest: DateTime type with additional functionality *