eliashaeussler/deep-closure-comparator
PHPUnit comparator/assertion that deeply compares closures inside objects/arrays by serializing them via opis/closure. Use DeepClosureAssert::assertEquals() as a drop-in replacement for PHPUnit’s assertEquals when closures should be treated as equal.
app()->middleware() configurations).Event::listen(fn($event) => ...)).app()->bind('service', fn() => ...)).$closure = fn($x) => $x + $this->offset).same() or mocking frameworks fall short.opis/closure) is preferable to manual inspection.Adopt only if:
same() or custom comparators due to closure complexity (e.g., nested closures with captured variables or dynamic scopes).Avoid if:
qlty or other deprecated tools (though this package no longer bundles them).expect($closure)->toReturn() or Mockery) suffice for your use cases.For Executives: "This package solves a specific but critical testing gap for Laravel applications where closure behavior directly impacts core functionality—like middleware or event systems. While adoption is minimal and maintenance is single-handed, recent updates (including PHPUnit compatibility) suggest it’s actively maintained. We’d recommend pursuing this only for high-priority features where closure testing is a blocker, as the risk-reward trade-off favors custom solutions otherwise. The alternative—manual test assertions or flaky comparisons—could introduce bugs in production."
For Engineering:
*"The package now drops qlty and updates dependencies, but its niche focus and lone maintainer remain risks. Use it only for closure-heavy test cases where alternatives like PHPUnit’s same() or mocking frameworks fail. Key considerations:
$this, container bindings, or database queries—edge cases may require custom handling.Proposal: Pilot this in a non-critical module first to validate integration and edge cases before wider adoption."*
How can I help you explore Laravel packages today?