Another small helper feature coming to Laravel 8 is the ability to fluently time travel in your tests. This will allow you to easily test for things like what happens when a free trial ends, or a next billing date, etc. Here is a quick example that @enunomaduro shared on Twitter showing how you can use this new feature:
1// Travel forward five minutes2$this->travel(5)->minutes;3$this->get($route)->assertSee('Created 5 mins ago');45// Travel forward one year6$this->travel(1)->year;7$this->get($route)->assertSee('Created 1 year ago');89// Travel to the given date time10$this->travelTo($user->trial_ends_at);11$this->get($route)->assertSee('Your free trial is expired');
Under the hood, this is a wrapper to Carbon’s setTestNow and is designed to be a little more fluent than the default. Of course, usage is optional but it’s one of those little things that aim to make your development life a little easier.