Laravel Testing & Packages: 5 Reads That’ll Change How You Write Tests

Testing is the thread running through this whole batch. Not “does it pass,” but “does a green suite actually mean the feature works.”

  • Testing Actions, Not Mocks: Steve McDougall makes the argument I most want every junior on my team to internalize: mocking your own Action class tests the wiring instead of the behavior. Delete the action’s body and a mock-based controller test still passes. His fix is to run Actions against a test database, assert on outcomes such as “a lead with this email now exists,” and reserve mocks for boundaries outside your control, including third-party APIs, outbound mail, and the queue.

  • A Clean Approach to Testing Events and Listeners: Joel Clermont applies the same idea to events. A feature test uses Event::fake() and assertDispatchedTimes() to confirm dispatch without running the listener. A separate integration test calls each listener’s handle() method directly. This cleanly separates the controller’s responsibility from the listener’s behavior and keeps both tests easy to understand.

  • Storage Cache Store in Laravel 13.10.0: The headline feature is a new storage cache driver that uses any configured filesystem disk, including S3, as a key/value cache without extra packages. The release also adds a --stop-when-empty-for flag for exiting idle queue workers, a WorkerIdle event, and lifecycle callbacks on Schedule::group(). Those callbacks let you attach onFailure or onSuccess once to a group of scheduled tasks.

  • Server-Side Rate Limiting in Laravel with Fingerprint.dev: Every IP-keyed rate limiter eventually encounters the same problems. Shared office NATs punish innocent users, VPN rotation weakens the limit, and carrier-grade NAT puts thousands of mobile subscribers into one bucket. This guide wires Fingerprint.dev’s device-identification API into Laravel middleware with Redis caching. It caches failures as well as successes to protect the API quota, then keys RateLimiter::for() on the verified visitor ID with an automatic IP fallback.

  • Simple Feature Flags for Laravel with Laravel Toggle: Pennant supports user-segmented rollouts; Laravel Toggle deliberately provides global on/off switches backed by .env, the database, or both. Specific database_flags can be changed from an admin screen, allowing an editor to enable a breaking-news banner without a deployment while stable flags remain locked to .env.