Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Time Mock Bundle Laravel Package

acts/time-mock-bundle

Symfony bundle for mocking and controlling time in tests and development. Freeze, fast-forward, and reset “now” to make time-dependent code deterministic, simplify assertions, and avoid flaky tests across DateTime/Clock usage.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Testability & CI/CD Efficiency: Enables reliable, deterministic unit/integration testing for time-sensitive logic (e.g., scheduled jobs, timeouts, or date-based workflows) by decoupling tests from real-world time fluctuations. Reduces flaky tests and speeds up CI pipelines.
  • Feature Roadmap for Time-Dependent Features: Justifies building features like:
    • Time-based access controls (e.g., "expire after 24h").
    • Scheduled notifications or reminders.
    • Rate-limiting tied to time windows.
    • Audit logs with timestamps. By mocking time, PMs can validate these features in isolation before integrating with real-time systems (e.g., databases, APIs).
  • Build vs. Buy: Avoids reinventing a time-mocking wheel (e.g., custom test utilities or manual DateTime overrides). Lowers dev overhead and technical debt.
  • Use Cases:
    • Legacy System Modernization: Safely refactor time-sensitive code in monoliths by mocking dependencies before full migration.
    • Multi-Tenant SaaS: Test tenant-specific time zones or local time logic without global side effects.
    • Compliance/Regulatory Features: Validate time-based compliance checks (e.g., GDPR "right to erasure" deadlines) in tests.

When to Consider This Package

  • Adopt if:
    • Your app relies on DateTime, Carbon, or Symfony’s ClockInterface for core logic (e.g., payments, subscriptions, or workflows).
    • Time-sensitive tests are flaky or slow due to real-time dependencies (e.g., waiting for cron jobs).
    • You’re using Symfony2 and need a lightweight, battle-tested solution (vs. rolling your own mocks).
    • Your team prioritizes testability and wants to avoid global state pollution (e.g., date_default_timezone_set hacks).
  • Look elsewhere if:
    • You’re not using Symfony2 (this bundle is framework-specific; alternatives like Mockery or PHPUnit extensions may suffice).
    • Your time logic is trivial (e.g., only displaying current time to users) and doesn’t need testing.
    • You require advanced time travel (e.g., freezing time mid-test) or time zone granularity—consider clockwork/clockwork or spatie/temporal-tests.
    • Your team lacks PHP/Symfony expertise to integrate bundles (evaluate maintenance cost).

How to Pitch It (Stakeholders)

For Executives: "This package lets our dev team write faster, more reliable tests for time-sensitive features—like subscriptions or compliance deadlines—without waiting for real clocks. It’s like hitting ‘pause’ on time in our tests, so we can catch bugs early and ship features like scheduled payments or reminders with confidence. The cost? Minimal: a one-time setup for our Symfony apps, with zero runtime overhead. It’s a force multiplier for our engineering team, especially as we scale features that depend on time."

For Engineering: *"The acts/time-mock-bundle gives us a clean way to mock time in Symfony2 tests, replacing fragile workarounds like DateTime::setTestNow(). Key benefits:

  • Deterministic tests: No more ‘test failed because the clock moved’—freeze time at will.
  • Symfony-native: Integrates with ClockInterface and Time component, so it plays nice with modern Symfony.
  • Lightweight: Just 1 dependency, no global state pollution. Use case: Mocking a user’s ‘last login’ timestamp to test session expiration logic, or simulating a 24-hour cooldown period in tests. Downside? Symfony2-only, but if we’re already using it, this is a no-brainer for test reliability."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle