PHP code example of paksuco / dusk-time-travel

1. Go to this page and download the library: Download paksuco/dusk-time-travel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paksuco / dusk-time-travel example snippets



    use \Paksuco\DuskTimeTravel\Browser as TimeTravelBrowser;

    class DuskTestCase extends BaseTestCase {

        protected function newBrowser($driver)
        {
            return new TimeTravelBrowser($driver);
        }

    }

// test case
$this->browse(function ($browser) {

    // on the homepage, you will see today's date as the current date.
    $browser->visit("home")
        ->travelTo(Carbon::tomorrow());

    // but, like this, you'll see tomorrows date as the current date
    $browser->travelTo(Carbon::tomorrow())
        ->visit("home");


    // an example use case, do something in yesterdays date and expect it to see today.
    $browser->travelTo(Carbon::yesterday())->visit($itemDetailsPage)
        ->doStuffInYesterdaysDate()
        ->travelBack()->visit($itemDetailsPage)
        ->assertSee(Carbon::yesterday());
});