Kernel::Test::Role::Environment::ProvidesFixedTime

NAME

Kernel::Test::Role::Environment::ProvidesFixedTime – role to mock the system time during tests.

FixedTimeSet()

makes it possible to override the system time during the test. You can pass an optional time parameter that should be used, if not, the current system time will be used.

All calls to methods of Kernel::System::DateTime will use the given time afterwards.

    $Self->FixedTimeSet(366475757);         # with Timestamp
    $Self->FixedTimeSet($DateTimeObject);   # with previously created DateTime object
    $Self->FixedTimeSet();                  # set to current date and time

Returns: Timestamp

This also affects Selenium tests for subsequent requests, but please note that this does NOT work in webpack development server environments, only with the Perl production or development web servers.

FixedTimeUnset()

restores the regular system time behavior.

FixedTimeAddSeconds()

adds a number of seconds to the fixed system time which was previously set by "FixedTimeSet()". You can pass a negative value to go back in time.

Scroll to Top