Pest Plugin Test Time banner
spatie spatie

Pest Plugin Test Time

Testing community

Description

A Pest plugin to control the flow of time

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

A Pest plugin to control the flow of time

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/pest-plugin-test-time.svg?style=flat-square)](https://packagist.org/packages/spatie/pest-plugin-test-time) [![Tests](https://github.com/spatie/pest-plugin-test-time/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/pest-plugin-test-time/actions/workflows/run-tests.yml) [![Total Downloads](https://img.shields.io/packagist/dt/spatie/pest-plugin-test-time.svg?style=flat-square)](https://packagist.org/packages/spatie/pest-plugin-test-time)

This [Pest](https://pestphp.com) plugin offers a function `testTime` that allows you to freeze and manipulate the current time in your tests.

use function Spatie\PestPluginTestTime\testTime;

testTime()->freeze(); // time will not change anymore

testTime()->addMinute(); // move time forward one minute

It also contains a custom expectation called `toBeCarbon` to easily check the values of `Carbon` instances.

$carbon = Carbon::createFromFormat('Y-m-d H:i:s', '2022-05-31 01:02:03');

// make an expectation on the whole date, including time
expect($carbon)->toBeCarbon('2022-05-31 01:02:03');

// make an expectation on only the date part
expect($carbon)->toBeCarbon('2022-05-31');

// explicitly pass in a format
expect($carbon)->toBeCarbon('2022', 'Y');

Support us

[](https://spatie.be/github-ad-click/pest-plugin-test-time)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual