Repository navigation
Use Double across core framework tests - #747
Conversation
Replace direct Mockery doubles across AI, API clients, authentication, broadcasting, bus, top-level cache, connection pools and non-scheduler console tests. Keep Mockery-backed framework APIs and existing PHPUnit doubles intact. Preserve required arguments, object identity, forbidden calls and verification counts with native doubles. Use initialized partials and real containers where appropriate, explicit callback capture, and local operation sequences for cross-double ordering. Declare dynamic Redis and console methods in typed test fixtures without changing production APIs. Consolidate duplicate Redis lock suites while retaining all distinct acquisition, ownership, callback and cleanup coverage. Verify ApiResource's unknown-method behavior against the real response rather than a mocking-library exception. Strengthen the untouched-parent timestamp assertion and correct the Redis integration comment. Validation: every changed test class and fixture consumer passed individually, including coroutine, cleanup and cancellation cases. Existing serializer-build skips remain. Root, type-fixture and skeleton static analysis passed; repository and skeleton formatting completed; git diff --check passed.
Replace direct Mockery doubles in the Redis cache suite, remaining scheduler cases, Context, Cookie, Coordinator, Core, Coroutine, Data and the first Database test group. Preserve explicit call counts, forbidden calls, argument checks, cancellation ownership and cross-call ordering. Exercise Redis operations through initialized connections and strict native client doubles. Reuse concrete scan fixtures where cursor arguments must be updated by reference, retaining pagination and concurrent membership-repair coverage. Record scan inputs and metadata operations for existing assertions; remove one duplicate page test and an unreachable native null-scan case. Use real request, DTO and dispatcher objects where mocking adds no value. Keep scheduler default stubs from absorbing forbidden or excess calls. Resolve the database CLI Process through the existing container with explicit parameters, retaining fresh process ownership, launch options and streamed output while removing constructor interception and isolated test processes. Validation: every changed test file passed independently. The affected Redis cache group passed 491 tests with 2803 assertions. Source, type-fixture and skeleton static analysis passed, as did root/skeleton formatting and the final changed-file formatting and whitespace checks.
Replace remaining direct Mockery doubles across database lifecycle tests, DI, Doctor, Encryption, Engine, Filesystem, Fortify and Foundation. Preserve call counts, argument checks, ordering, exception identity and the existing framework APIs that still use Mockery internally. Use real configuration and exception objects where no double is needed. Exercise Flysystem forwarding through real adapters, keep stream reads in call resolvers, and record database trait ordering in its existing fixture. Make the renderer isolation test actually interleave its coroutines, remove redundant framework cleanup, and delete an unused query-builder test base. Complete ViewFinderInterface with getHints(), alongside its existing namespace-registration methods. Remove concrete-finder assumptions from view caching and analyzer discovery, cover namespaced roots in the command test, and document the contract requirements for custom implementations. Tighten tagged-cache flush tests to reject extra native Redis commands and incorrect keys while preserving the two checks needed for racing writers. Validation: each changed test file passed, including the existing analyzer namespace-discovery and cache-invalidation tests. The existing GCS skip is unchanged. Full static analysis, formatting and whitespace checks passed.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoUse Double across remaining framework tests
AI Description
Diagram
High-Level Assessment
Files changed (268)
|
Code Review by Qodo
1. Custom view finders prevent apps from loading
|
[Medium impact] The PR appears safe to merge; the previous pruning-test finding is fixed and no new actionable issues were found. SummaryReplaces direct Mockery doubles with
Reviews (2) · Last reviewed commit: "Preserve cache tests against unexpected ..." · Reviewed by Greptile |
| $table->shouldReceive('useWritePdo')->andReturnSelf()->byDefault(); | ||
| $resolver = Double::for(ConnectionResolverInterface::class); | ||
| $connection = Double::for(Connection::class); | ||
| $table = Double::for(Builder::class); |
There was a problem hiding this comment.
Disabled pruning loses its guard
The shared query builder is now lenient. testLockCanBeAcquiredWithoutAutomaticPruning only expects insertOrIgnore, so unexpected where(...)->delete() calls can now succeed silently. The old Mockery double rejected those calls. This loses the test’s guard against deleting lock rows when pruning is disabled.
Make this builder strict, or explicitly forbid pruning calls in that test.
There was a problem hiding this comment.
Fixed: the query builder is strict in the disabled-pruning test, so unexpected pruning calls fail. The affected tests pass.
Make the disabled-pruning query builder and stack cache layer doubles strict so unconfigured reads, writes and deletions fail as they did before the Double conversion. Apply the same protection to tagged cache layers while retaining explicit negative assertions and real-store compensation coverage. All three affected test files pass. Full formatting and the final targeted formatting check pass. No production behavior or dependency requirements change.
|
Regarding the custom view finder finding: getHints() is an intentional contract addition for Hypervel 0.4. The finder contract already supports adding, prepending and replacing namespace hints; consumers need to retrieve those hints without depending on FileViewFinder. Custom implementations must implement getHints(), as documented in the porting guide. An optional interface and fallback would preserve an incomplete contract, so this change remains. |
Test doubles
Replace direct Mockery doubles with Double across AI, authentication, cache, console, coroutine, Data, database, filesystem, Fortify and Foundation tests, including their supporting packages. Keep existing PHPUnit doubles and framework APIs backed by Mockery.
The conversion preserves required calls, arguments, ordering, forbidden calls and exception behavior. Tests use real objects where mocking adds no value. Redis cache tests exercise real connection forwarding with strict native-client doubles, and scan tests use concrete clients to preserve cursor updates by reference. Duplicate Redis lock coverage is consolidated and an unused query-builder test base is removed.
Supporting changes
getHints()toViewFinderInterface, alongside namespace registration. View caching and static analysis can discover namespaced views through the contract without assumingFileViewFinder. Document the requirements for custom finders.Verification
Changed test files and affected fixture consumers pass individually, including Redis cache coverage and analyzer view-discovery/cache-invalidation tests. Existing dependency and serializer-build skips remain unchanged. Full static analysis, root and skeleton formatting, and whitespace checks pass.
Note
Replace Mockery with JMac test doubles across core framework tests
JMac\Testing\Doublewith theVerifiesDoublesPHPUnit trait, converting return values, argument matchers, callbacks, call counts, and exceptions to the new API across cache, database, auth, console, coroutine, AI, filesystem, and foundation tests.Requestinstances, concreteFlattenExceptionandDataobjects, a real Hypervel container, and a real Events Dispatcher inDatabaseIntegrationTest.FakeRedisClient,PruneRedisClusterClient) record calls for explicit assertions.getHints(): arrayto ViewFinderInterface.php; custom view finder implementations must now providegetHints(),prependLocation(), andgetPaths().DbCommand::handlenow resolves its SymfonyProcessthrough the container instead of constructing it directly.AddTest/FlushTestno longer fail whenpipelineis invoked,testTouchingParentin EloquentBelongsToManyTest.php now expects09:10:10, andDatabaseDbCommandLaunchTestdropped its separate-process attributes. TheVerifiesDoublestrait enforces double verification in every migrated test class.Macroscope summarized 4d4ad4a.