Skip to content

Commit

Permalink
Merge pull request #52233 from timacdonald/fix-tests
Browse files Browse the repository at this point in the history
[11.x] Support lower version of Carbon
  • Loading branch information
timacdonald authored Jul 22, 2024
2 parents a13b726 + 65823de commit 426d0bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/Foundation/Testing/WormholeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Carbon\CarbonImmutable;
use Illuminate\Foundation\Testing\Wormhole;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -53,13 +54,14 @@ public function testCarbonImmutableCompatibility()

public function testItCanTravelByMicroseconds()
{
Date::use(CarbonImmutable::class);
Date::setTestNow(Date::parse('2000-01-01 00:00:00')->startOfSecond());
Carbon::setTestNow(Carbon::parse('2000-01-01 00:00:00')->startOfSecond());

(new Wormhole(1))->microsecond();
$this->assertSame('2000-01-01 00:00:00.000001', Date::now()->format('Y-m-d H:i:s.u'));

(new Wormhole(5))->microseconds();
$this->assertSame('2000-01-01 00:00:00.000006', Date::now()->format('Y-m-d H:i:s.u'));

Carbon::setTestnow();
}
}

0 comments on commit 426d0bc

Please sign in to comment.