Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Change Wormhole to use the Date Factory #35421

Merged
merged 2 commits into from Nov 30, 2020
Merged

Conversation

kalfheim
Copy link
Contributor

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.

None yet

2 participants