Repository navigation
Restore strict expectations in tests converted to Double - #114
Conversation
A failed pool release previously left later idle leases in the coroutine context holding their physical sessions. Attempt each release before propagating the first failure, giving a caller cancellation precedence as in terminal connection cleanup. Exercise the public database manager with two failing leases to check that both are visited and that the correct exception reaches the caller.
The released version can lose expectation failures caught by application code. Use the development branch containing the final-verification fix so forbidden calls still fail their tests.
Distinguish value comparison from the exact-instance matcher so converting a Mockery expectation preserves identity where the test relies on it.
Role assignment dispatches the event as one argument. Match that call so the never expectation directly identifies a forbidden dispatch when the event has no listeners.
QueueManager must supply the application that owns each connection. Match the exact instance when assigning or replacing it so the expectations remain meaningful even when two containers have equal state.
The SDK handler records a command before rejecting it with a queued exception. Check its name after the exception reaches the caller so a different failing operation cannot satisfy the deletion test.
An empty AWS mock handler throws before recording the command. Its last-command value cannot show whether a send was attempted here. Keep the checks for the original preparation failure and the events delivered for each outstanding job.
A predicate can be evaluated again to explain a mismatch. Keep the SQLite state check free of side effects and record the update in the response callback so the operation log reflects accepted calls.
Group the Double verification trait alphabetically with the database, Redis and rate limiter test traits. Describe the unlink fixture in terms of the deletion batches it records.
Preserve the unexpected-call checks of plain Mockery mocks when converting them to Double. Record arguments and call effects only after an expectation matches, since Double can evaluate predicates while considering other expectations or explaining a mismatch.
Use the same default for Hypervel tests and tests imported from upstream. Keep loose behavior where a test deliberately permits unrelated calls.
Configure the test doubles used by model gateways, tool execution and service clients to reject unconfigured calls. Keep each test’s existing return values, ordering and required interactions.
Check the exact user sent to credential validation, password rehashing and token storage. Record remembered logins only when the expected dispatch occurs. Use strict doubles for configured collaborators, retaining the intentionally loose store validator, and verify the actual cached result and no-op guard behavior.
Reject unconfigured collaborator calls in the broadcaster tests. Capture Mercure updates after the publish expectation matches, so diagnostic matcher evaluations cannot change the value inspected by the test.
Check the queued batch chain and its trailing closure, and verify the serialized options passed to the PostgreSQL insert. Require the original job on forwarded dispatches and forbid all instances of faked job classes from reaching the real dispatcher.
Check the event, inverse-relation callback, validation input and SQS cleanup exception that each double actually received. Keep existing type and value assertions, and reject unrelated calls on the configured collaborators.
Read forwarded IP headers in the response callback of each matched Algolia search. Keep the argument matchers free of side effects so evaluating candidate calls cannot add duplicate observations.
Register one finite factory expectation for each test and return its connection proxies in order. This catches extra lookups while preserving the distinct clients used in read, write and retry phases.
Clarify why normalized policy guesses prevent duplicate worker-lifetime instances. Mark the intentional store-wide event behavior next to the ported cache assertion so future upstream updates preserve it.
Require the repository selected by the user provider for both cache fills. In broadcasting, verify the rescued exception by identity and forbid reporting any exception on cancellation.
Make unexpected calls to the Redis collaborators fail, including in the tag rewrite integration test. Let Redis exceptions retain their trace when flushing a missing tag and check that the other tag still holds its value.
Select strict mode on store, lock and command doubles. Require interval error reporting before exercising the cache, while matching restored exceptions by class and message. Remove unconditional assertions where the existing call expectations or failure checks already cover the behavior.
Use strict doubles in the pool fixture and its connection and idle monitor tests. This makes additional calls during checkout, keepalive and release visible to those tests.
Require the scheduled event, application and reported exception to be the original instances. Share the scheduling process fixture so each strict double allows the stop call Symfony makes on destruction.
Require the same command to be unregistered when signal handling finishes. Give the prohibition message a real null output and keep command interactions explicit across the console fixtures.
Reject unconfigured calls to contextual binding and cookie collaborators. Express the timer no-throw case directly through PHPUnit when clearing a nonexistent timer.
Require exception handlers to receive the original failure from lifecycle hooks and coroutine cleanup. Make unexpected interactions with the workers, waiters and signal collaborators fail at the call site.
Declare strict mode for the collaborators exercised by collection creation and transformation. Unexpected calls can then fail even when the transformed return value would still match.
Remove the unconditional assertion. A failure during termination now reaches PHPUnit directly, and the test declares that normal return is the expected outcome.
Reject unexpected interactions during client discovery and launch. Allow the stop call made by the Symfony process destructor while verifying how the database command builds and runs the client.
Let the same scope test run against standard, team and custom permission models. This replaces a passing placeholder and checks inverse scope behavior on UUIDs as well. Verify the teams-disabled migration leaves the team column absent.
Make request and response collaborators strict and check the response carried by request exceptions. Express void capability checks directly when normal return is the result under test.
Require the original cancellation or cleanup exception at the reporting boundary. Verify deferred telemetry forwards the original callbacks, instruments, log record and context.
Check the exact request, user and cache repository when credentials are validated and token state is invalidated. Reject unconfigured calls on the authentication collaborators.
Check both dispatched notification jobs after dispatch and require the original notification and recipient. Exercise fake and real process results through their fluent return values.
Check partial publication order when the exception is reported. Capture the settled result and inspect the worker options supplied by the console command without running assertions inside matchers.
Require the original Beanstalk job and SQS cleanup failure. Forbid resolving the overflow cache on release cancellation, and check Redis bulk script arguments after publication.
Freeze the pruning cutoff so a zero-hour argument has an observable result. Keep the real dispatcher for ordinary retries, and verify selected dispatches and daemon failures explicitly in worker tests.
Use strict collaborators for job dispatch, queue routing, state changes and batches. Verify custom collection restoration and require cancellation to propagate through sync payload serialization.
Configure the cluster mode once on the strict limiter fixture. Keep the real pool context key and check that registering event callbacks leaves an unbound event dispatcher alone.
Check that a subscriber receives messages for its channel and that releasing an unclaimed slot preserves the connection cap on both storage backends. Check which application, payload and shutdown errors are forwarded.
Verify that a route added to a compiled collection is available by name and that Scout’s no-op engines leave the stored model in place. Make the intended collaborator interactions explicit.
Require configured calls in the transport and session tests and match forwarded requests and failures by identity. This catches substitutions that compare equal.
Verify the value returned by the Timebox callback and that Sleep callbacks stay idle outside fake mode. Match the actual queued jobs and reported exceptions.
Record skip callbacks and check them after processing the attributes so missing callbacks fail the tests. Verify the queue payload hook consumed its one-time binding and check the output and exception sent to the console handler.
Match the query and values passed through to the ordinary presence verifier. Count each rejected condition after catching the expected type error and make the no-throw constructor checks explicit.
Verify that composers receive the view being rendered and custom engines receive the registered resolver. Require configured interactions from the view and watcher collaborators.
Bind the handlers under test in an isolated container so service resolution and the exception-reporting fallback run normally. Check cancellation and listener failures by identity and make the expected log calls explicit.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Code Review by Qodo
1. CI tests can change without a code change
|
PR Summary by QodoRestore strict Double expectations and complete idle connection cleanup
AI Description
Diagram
High-Level Assessment
Files changed (528)
|
[Medium impact] The follow-up changes appear safe to merge; the earlier cleanup-reporting issue is non-blocking.
|
| } catch (Throwable $exception) { | ||
| $failure = Coroutine::preferCancellation($failure, $exception); |
There was a problem hiding this comment.
When one lease throws a normal cleanup error and a later lease throws CanceledException, this call replaces the first error without reporting or chaining it. The first error used to reach the caller; now only cancellation escapes. Later normal errors are also silently dropped once a failure is kept.
Report each displaced error while still draining every lease. FailureReporter::preferCancellation() already preserves the same priority while reporting the error that loses it.
There was a problem hiding this comment.
Idle release now tries every lease and then propagates the first failure, with cancellation taking precedence. This follows the cleanup behavior documented in the coroutine guide and used by terminateConnections() and closePools(). The two-lease regression covers both ordinary failure and cancellation.
There was a problem hiding this comment.
Agreed. I treated displaced cleanup errors as needing separate reporting, but that does not match the established cleanup contract here: terminateConnections() and closePools() also drain all resources, then propagate one selected failure with cancellation taking precedence. The two-lease regression covers that behavior. I withdraw the finding; no additional error reporting is needed.
Use a connected client in atomic mode on the default database for ordinary releases. This exercises the pool return path after clearing WATCH state and preserves the mode check.
Guzzle checks the stream timeout metadata when a read throws. Give it a negative result so the body export test exercises the original read failure and verifies that the caller keeps its open resource.
Return the route middleware for the deferred WebSocket handshake. Allow the SDK to look up its optional OTLP integration when another test has installed the process-wide propagation callback.
The caster visits several application properties. Require the failing property and the later version lookup while allowing the other reads to return their defaults.
|
The root development dependency follows Double master deliberately so the suite can use the fix for caught expectation failures. A fresh install can pick up upstream changes, and CI exercises that combination. This requirement applies only to contributors running the framework test suite. |
Double accepts unexpected calls by default and compares object arguments by value. Some tests lost checks when they moved from Mockery. They could pass if a handler received a different instance or if code called an unexpected method.
The tests now use strict doubles unless they deliberately ignore unrelated calls. They check object identity where the same request, job, connection or exception must be passed through. Tests that record arguments do so after a call matches. The suite uses Double's development branch for its fixes to expectation verification.
Several tests now check the result directly. For example, the permission scope tests exercise both integer and UUID keys, and the Reverb test checks that a subscribed socket actually receives the broadcast.
There’s also a fix for idle database connections. If releasing one lease throws, the resolver now attempts to release the remaining leases before propagating the failure. Cancellation takes precedence if cleanup encounters both cancellation and another error.
Summary by cubic
Restores the strictness lost when tests moved from Mockery to Double, so unexpected calls and object substitutions can no longer pass silently.
strict()doubles andArgument::same()where instance identity matters.jasonmccreary/doubletodev-masterfor fixes to expectation verification.ConnectionResolver::releaseIdleConnections()releases every idle lease before propagating the first failure, with cancellation taking precedence.Written for commit 3dab76a. Summary will update on new commits.
Note
Restore strict expectations in tests converted to Double
Argument::samefor identity matching of objects,Argument::captureplus post-call assertions instead of side-effecting matcher callbacks, andexpectNotToPerformAssertions()instead of trivialassertTrue(true)placeholders.with()compares objects with==and recommendsArgument::same()for exact-instance matching.jasonmccreary/doubleconstraint in composer.json from^1.1.1todev-master.releaseIfIdlecall no longer aborts the loop; remaining idle values are still released, then the preferred failure (cancellation preferred viaCoroutine::preferCancellation) is thrown.Process::stopon destructor,isMaria) now require allowances; the ConnectionResolver cleanup fix changes failure propagation when multiple idle releases throw.Macroscope summarized 3dab76a.