Skip to content

Add Carbonite for time manipulation in tests#30

Open
thinkstylestudio wants to merge 3 commits into
developfrom
feature/add-carbonite-2249
Open

Add Carbonite for time manipulation in tests#30
thinkstylestudio wants to merge 3 commits into
developfrom
feature/add-carbonite-2249

Conversation

@thinkstylestudio
Copy link
Copy Markdown

Summary

Adds kylekatarnls/carbonite as a dev dependency so tests can freeze, accelerate, decelerate, and elapse time using Carbon.

Closes #10.

Changes

  • Install kylekatarnls/carbonite ^2.0 (dev)
  • Enable BespinTimeMocking for Feature and Unit tests so each test resets the timeline automatically
  • Add Pest helpers fakeAsync() and tick() (Carbonite’s Angular-style testing pattern)
  • Add unit tests covering freeze, accelerate, decelerate, elapse, speed, and tick

Usage

use Carbon\Carbon;
use Carbon\Carbonite;

Carbonite::freeze('2024-01-01');
Carbonite::elapse('1 week');

expect(Carbon::now()->format('Y-m-d'))->toBe('2024-01-08');

Carbonite::accelerate(2);  // time passes twice as fast
Carbonite::decelerate(2);  // time passes half as fast

Or with Pest helpers:

fakeAsync(function () {
    $now = Carbon::now();
    tick(2000);
    expect($now->diffForHumans())->toBe('2 seconds ago');
});

Test plan

  • php artisan test tests/Unit/CarboniteTest.php
Open in Web Open in Cursor 

Justin Rhodes and others added 3 commits August 11, 2025 21:01
Install kylekatarnls/carbonite as a dev dependency and enable
BespinTimeMocking so each test gets a clean timeline. Add Pest helpers
fakeAsync() and tick(), plus unit tests for freeze, accelerate,
decelerate, elapse, and speed.

Closes #10

Co-authored-by: Theron Smith <theron+github@thinkstylestudio.com>
@thinkstylestudio thinkstylestudio marked this pull request as ready for review May 20, 2026 06:44
@thinkstylestudio thinkstylestudio self-assigned this May 20, 2026
@thinkstylestudio thinkstylestudio changed the base branch from main to develop May 20, 2026 07:15
Copy link
Copy Markdown

@dpellenwood dpellenwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏

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.

Add Carbonite to speedup and slow down time using Carbon

3 participants