spatie/test-time
Control time in tests with Spatie TestTime—freeze or advance Carbon-based timestamps dynamically for time-sensitive assertions. Simplify testing date-dependent logic by manually adjusting time without altering real-world clocks. Works seamlessly with Carbon’s methods like addYear(), subDay(), or cus...
Architecture fit is excellent as Laravel's default time handling relies on Carbon, which this package directly manipulates. It's designed as a dev dependency for testing, aligning perfectly with Laravel's testing workflow. Integration feasibility is high due to minimal setup (composer require --dev) and straightforward API. Technical risks include potential global state side effects if not properly managed (e.g., forgetting to unfreeze), and compatibility dependencies on Carbon's internal behavior—though the package explicitly supports Carbon 2.63+ and 3.0. Key questions: How does it handle parallel test execution (e.g., Pest's parallel mode)? Does it reset state automatically between tests? What happens if an exception occurs before unfreeze()? How does it interact with Laravel's built-in time mocking helpers like now() or Carbon::setTestNow()?
Stack fit is seamless with Laravel's testing ecosystem (PHPUnit/Pest), as it replaces manual time mocking with a dedicated helper. Migration path involves replacing existing time manipulation code (e.g., Carbon::setTestNow()) with TestTime::freeze() and related methods in test setups. Compatibility is strong for Laravel 8+ (Carbon 2) and Laravel 10+ (Carbon 3), with explicit version constraints in composer.json. Sequencing should prioritize new tests
How can I help you explore Laravel packages today?