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

Callable Fake Laravel Package

timacdonald/callable-fake

A tiny PHP testing utility for faking/invoking callables. CallableFake lets you replace closures or invokable objects, record calls and arguments, assert usage, and return configured values—useful for isolating behavior in PHPUnit/Laravel tests.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Improved Test Coverage for Callable/Closure Logic: Enables rigorous testing of event handlers, middleware, or service callbacks where direct invocation is impractical.
  • Decoupling Dependencies in Unit Tests: Reduces reliance on external services (e.g., APIs, databases) by faking callables, accelerating test execution and isolation.
  • Roadmap for PHP 8.2+ and PHPUnit 10/11/12: Aligns with modern stack adoption, justifying upgrades to newer PHPUnit versions for long-term maintainability.
  • Build vs. Buy: Avoids reinventing mocking logic for closures, saving dev time while maintaining flexibility (MIT license allows customization).
  • Use Cases:
    • Testing Laravel event listeners or queue jobs.
    • Validating middleware invocations (e.g., auth, rate-limiting).
    • Mocking service providers or container bindings.

When to Consider This Package

  • Adopt if:

    • Your team uses PHP 8.2+ and PHPUnit 10+ (or plans to upgrade).
    • You frequently test closures, callables, or anonymous functions in isolation.
    • You need fine-grained control over fake invocations (e.g., asserting call order, arguments, or return values).
    • Your tests are slow due to external dependencies (e.g., HTTP clients, databases).
  • Look elsewhere if:

    • You’re on PHP <8.2 or PHPUnit <10 (use older versions or alternatives like Mockery).
    • Your use case is better served by built-in PHPUnit mocks (e.g., simple method stubs).
    • You need advanced mocking features (e.g., recursive mocks, partial mocks) → consider Mockery or PHPUnit's native tools.
    • Your team prefers type-safe mocking (e.g., pestphp/pest-plugin-mocks).

How to Pitch It (Stakeholders)

For Executives: "This lightweight package lets our PHP team test complex callable logic faster and more reliably by faking closures/middleware—reducing flaky tests tied to external services. It’s a low-risk upgrade (MIT license, PHP 8.2+ support) that aligns with our modern stack and cuts test maintenance time by 20–30%."

For Engineering: *"CallableFake is a PHPUnit-compatible utility to mock closures with precision:

  • Fake invocations of event handlers, middleware, or service callbacks.
  • Assert call counts, arguments, or return values (e.g., assertCalledTimes(3)).
  • Drop-in for PHP 8.2+ and PHPUnit 10/11/12—no breaking changes if we upgrade. Example: Replace slow HTTP mocks in queue job tests with instant fake callbacks. Zero dependencies, MIT licensed, and actively maintained (last release: March 2025)."*

For QA/DevOps: "This tool speeds up CI/CD by isolating tests from external services. For example, testing a Laravel event listener now requires no database/API setup—just fake the closure and verify its behavior. Reduces test flakiness and false positives."

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky