From 40e00c1fa277a8f04bc33700ede93a1a4e4c5568 Mon Sep 17 00:00:00 2001 From: nasser Date: Wed, 16 Feb 2022 13:38:40 +0330 Subject: [PATCH] fix yesterday test now --- src/Traits/Creator.php | 9 +++++---- tests/ComparisionTest.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Traits/Creator.php b/src/Traits/Creator.php index f9898ba..2bd153d 100644 --- a/src/Traits/Creator.php +++ b/src/Traits/Creator.php @@ -18,6 +18,7 @@ trait Creator */ public function __construct($datetime = null, $timezone = null) { + $dt = $datetime; if (static::$testNow) { $dt = static::$testNow; } elseif (empty($datetime)) { @@ -59,7 +60,7 @@ trait Creator */ public static function today($timezone = null) { - return (new static($timezone))->startDay(); + return (new static(null, $timezone))->startDay(); } /** @@ -71,7 +72,7 @@ trait Creator */ public static function tomorrow($timezone = null) { - return (new static('+1 day', $timezone))->startDay(); + return (new static(null, $timezone))->addDay()->startDay(); } /** @@ -83,14 +84,14 @@ trait Creator */ public static function yesterday($timezone = null) { - return (new static('-1 day', $timezone))->startDay(); + return (new static(null, $timezone))->subDay()->startDay(); } /** * Create a Verta instance from a DateTime one * * @param $datetime [optional] - * @param bool $timezone [optional] + * @param \DateTimeZone|string|null $timezone [optional] * * @return static */ diff --git a/tests/ComparisionTest.php b/tests/ComparisionTest.php index a4519ef..b0cab96 100644 --- a/tests/ComparisionTest.php +++ b/tests/ComparisionTest.php @@ -244,7 +244,7 @@ class ComparisionTest extends TestCase $this->assertEquals($result, Verta::parse('1398-10-10 21:30:55')); } - public function testIsDay() + public function testIs() { $datetime = Verta::parse('1397-10-10 21:30:50'); $target = Verta::parse('1398-10-10 21:30:01');