@@ -18,6 +18,7 @@ protected function setUp(): void
18
18
{
19
19
parent ::setUp ();
20
20
21
+ Carbon::setTestNow (now ());
21
22
Casting::truncate ();
22
23
}
23
24
@@ -55,7 +56,7 @@ public function testDatetimeAsString(): void
55
56
56
57
public function testDatetimeWithCustomFormat (): void
57
58
{
58
- $ model = Casting::query ()->create (['datetimeWithFormatField ' => new DateTime ( )]);
59
+ $ model = Casting::query ()->create (['datetimeWithFormatField ' => DateTime:: createFromInterface ( now () )]);
59
60
60
61
self ::assertInstanceOf (Carbon::class, $ model ->datetimeWithFormatField );
61
62
self ::assertEquals (now ()->format ('j.n.Y H:i ' ), (string ) $ model ->datetimeWithFormatField );
@@ -68,7 +69,7 @@ public function testDatetimeWithCustomFormat(): void
68
69
69
70
public function testImmutableDatetime (): void
70
71
{
71
- $ model = Casting::query ()->create (['immutableDatetimeField ' => new DateTime ( )]);
72
+ $ model = Casting::query ()->create (['immutableDatetimeField ' => DateTime:: createFromInterface ( now () )]);
72
73
73
74
self ::assertInstanceOf (CarbonImmutable::class, $ model ->immutableDatetimeField );
74
75
self ::assertEquals (now ()->format ('Y-m-d H:i:s ' ), (string ) $ model ->immutableDatetimeField );
@@ -89,7 +90,7 @@ public function testImmutableDatetime(): void
89
90
90
91
public function testImmutableDatetimeWithCustomFormat (): void
91
92
{
92
- $ model = Casting::query ()->create (['immutableDatetimeWithFormatField ' => new DateTime ( )]);
93
+ $ model = Casting::query ()->create (['immutableDatetimeWithFormatField ' => DateTime:: createFromInterface ( now () )]);
93
94
94
95
self ::assertInstanceOf (CarbonImmutable::class, $ model ->immutableDatetimeWithFormatField );
95
96
self ::assertEquals (now ()->format ('j.n.Y H:i ' ), (string ) $ model ->immutableDatetimeWithFormatField );
0 commit comments