Skip to content

Conversation

kalfheim
Copy link

I wanted to use CarbonImmutable by default in an app I'm building, and got caught up in a wormhole issue when trying to travel into the future.

Basically, this example currently doesn't work as expected:

<?php

namespace Tests\Feature;

use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Date;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    public function testItTravelsInTime()
    {
        Date::use(CarbonImmutable::class);

        $this->travel(10)->days();

        dump(now()); // Incorrectly dumps the current time
    }
}

This PR fixes the issue by making sure the Wormhole class references Illuminate\Support\Facades\Date facade instead of Illuminate\Support\Carbon.

Also added a test to make sure it works as expected.

@taylorotwell taylorotwell merged commit 7ade340 into laravel:8.x Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants