Skip to content

Adopt Double across core framework tests - #110

Merged
binaryfire merged 8 commits into
0.4from
upstream-sync-double-2026-11-16
Nov 16, 2026
Merged

binaryfire merged 8 commits into
0.4from
upstream-sync-double-2026-11-16

Conversation

@binaryfire

@binaryfire binaryfire commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Test doubles and real behavior

Adopt Double across core framework tests, following the upstream test conversion. Mockery-backed framework helpers and their integration tests remain supported, as do existing upstream PHPUnit doubles.

  • Replace direct Mockery mocks and spies with native Double collaborators and per-test verification.
  • Exercise real database rows, HTTP requests, sessions and SDK requests where the old tests mocked implementation details.
  • Move Redis behavior into service integration tests and consolidate replaced database coverage without losing distinct assertions.
  • Preserve Hypervel's coroutine isolation, cancellation, connection ownership, atomic writes and typed validation coverage.
  • Update testing and porting guidance so new tests use Double and future ports convert direct Mockery usage consistently.

Related fixes

  • Remove the ignored SES v1 Source parameter from the SES v2 transport, preserving raw sender headers and explicit SES options.
  • Preserve queue name "0" and nonempty zero identifiers in retry commands.
  • Declare gatherData(): array on the View contract because response assertions consume effective rendering data, including shared values. Custom View implementations must provide it; the standard View already does. Document this contract difference and track a broader contract-completeness audit.

Validation

Changed test classes and isolated Redis integration tests pass locally. Static analysis and formatting pass. The existing Redis Cluster CI job also covers the prefix regression without a Cluster skip.


Summary by cubic

Adopts Double for test doubles across core framework tests, following the upstream test conversion. Direct Mockery mocks and spies are replaced with native Double collaborators and per-test verification, while Mockery-backed framework helpers and upstream PHPUnit doubles remain supported.

  • Replace implementation mocks with real database rows, HTTP requests, sessions, and SDK requests.
  • Move Redis behavior into service integration tests and consolidate replaced database coverage without losing distinct assertions.
  • Preserve Hypervel coroutine isolation, cancellation, connection ownership, atomic writes, and typed validation coverage.
  • Update testing and porting guidance so new tests use Double and future ports convert direct Mockery usage consistently.
  • Retain behavioral coverage for translation registration before and after resolver, password-change session hashes, serialized SQS commands, nullable route lookups, unmatched relationship state, and attach-touch timestamps.

Related fixes

  • Remove the ignored SES v1 Source parameter from the SES v2 transport.
  • Preserve queue name "0" and nonempty zero identifiers in retry commands.
  • Declare gatherData(): array on the View contract because response assertions consume effective rendering data, including shared values.

Migration

  • Custom View implementations must provide gatherData(): array; the standard View already does.

Written for commit 5568bb0. Summary will update on new commits.

View guided diff Turn on auto-fix

Note

Adopt JMac Double test doubles across core framework tests

  • Migrates the framework test suites from Mockery to jasonmccreary/double (added in composer.json), using Double::for, Argument matchers, and the PHPUnit VerifiesDoubles trait across auth, bus, cache, database, queue, view, and broadcasting tests.
  • Replaces many mocked-collaborator setups with real implementations: in-memory SQLite fixtures for Eloquent createOrFirst/firstOrCreate/updateOrCreate relation tests, concrete containers, real Request objects, Carbon test clocks, and AWS SDK MockHandlers for SES and SQS tests.
  • Adds the gatherData(): array method to the View contract in View.php and documents it in README.md and porting-from-laravel.md.
  • Fixes queue retry commands in RetryCommand.php and RetryBatchCommand.php so the string IDs and queue name "0" are no longer dropped by falsey filtering. Also removes the v1-only Source field from SES v2 requests in SesV2Transport.php.
  • Behavioral Change: View contract implementers must add gatherData(); many legacy tests were deleted rather than migrated, so coverage for some Redis, model, and queue scenarios (e.g. DatabaseEloquentModelTest increment/destroy cases) is reduced; SesV2Transport requests no longer include Source.

Macroscope summarized 5568bb0.

Audit real consumers and implementation semantics for behavior every conforming implementation must expose. Treat Hypervel contracts as greenfield interfaces rather than inheriting missing declarations from Laravel.

Keep internal helpers and implementation-specific capabilities off general contracts, and update implementations, tests and public-contract documentation together during the audit.
Use Double for new test doubles and convert direct Mockery mocks and spies when porting from any upstream. Preserve upstream PHPUnit doubles and Mockery-backed framework helpers, with framework-owned cleanup and explicit Double verification.

Explain lenient argument matching, overlapping allowed calls that bypass maximum counts, native fluent self-returns and static-return requirements. Retain concrete model fixtures for distinct instances and remove redundant guidance.

Align the porting policy and checklists through links to the shared convention. Convert the Hypervel container and error-handler examples in the Hyperf guide, including the container control-name collision, while preserving the Hyperf source examples.
Add jasonmccreary/double ^1.1.1 as a development dependency for native test doubles and per-test verification. Retain Mockery for the framework testing APIs that expose its expectations and spies.

This prepares the test conversion from Laravel framework PR #61947 at c980cb5827c6512c12ac44493d172a593b41299a. Dependencies are installed independently in the worktree; the root lock file remains untracked.
SES v2 ignores Source, and the envelope sender can describe the return path rather than the FromEmailAddress identity. Remove the unsupported parameter while preserving raw sender headers, explicit SES options and recipient handling.

Replace transport mocks with the real SDK MockHandler and verify serialized HTTP payloads, message identifiers, tenant options and error behavior. Reconcile the transport test conversion from Laravel framework PR #61947 without mapping a bounce address to the sending identity.

Validation: MailSesV2TransportTest, all three static-analysis configurations and repository formatting pass.
Only omitted or empty queue options mean no queue filter. Preserve the valid queue name 0, and filter only empty strings from retry job and batch identifiers so nonempty zero identifiers reach repository lookup and not-found diagnostics.

Extend the existing regression datasets and convert the affected tests to native Double expectations and real SDK request handling. Preserve exact payloads, failure events and retry range behavior while reconciling Laravel framework PR #61947.

Validation: both retry command test classes, all three static-analysis configurations and repository formatting pass.
Response assertions consume gatherData through the View contract to inspect effective rendering data, including shared values. Declare gatherData(): array on that contract instead of relying on an undeclared concrete capability. The standard View already implements it.

Adapt the handwritten Markdown view fixture, document the requirement for custom implementations, and retain a source explanation of the deliberate Laravel contract difference. Convert TestResponse collaborators to native Double contracts while preserving streaming, JSON, session and model-identity coverage.

Validation: TestResponseTest and MarkdownCoroutineSafetyTest pass, as do all three static-analysis configurations and repository formatting.
Reconcile Laravel framework PR #61947 against c980cb5827c6512c12ac44493d172a593b41299a. Use native Double collaborators with per-test verification, preserving meaningful argument, identity, ordering, required-call and forbidden-call assertions.

Replace query and session plumbing mocks with real SQLite rows, HTTP requests and session state. Move Redis behavior into service integration coverage and exercise actual SDK command serialization. Remove obsolete database mock suites only after retaining their distinct coverage in integration tests.

Preserve Hypervel coroutine ownership, cancellation, pooling, immutable dates, atomic publication, typed validation and cache behavior. Keep real fixtures for native static return types, explicit container collision handling, established unsupported-driver exclusions and framework-owned state cleanup. Mockery-backed framework testing APIs and their dedicated tests remain supported.

Validation: every changed test class was run individually, including isolated Redis integration coverage. All three static-analysis configurations and repository formatting pass. The Redis SCAN_PREFIX regression runs in the existing Cluster CI job without a topology skip.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Adopt Double across framework tests and expand integration coverage

🧪 Tests 🐞 Bug fix 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Convert direct Mockery tests to Double while retaining framework-backed helpers and upstream
 PHPUnit doubles.
• Replace implementation mocks with database, Redis, HTTP, session, and SDK behavior tests.
• Fix SES v2 parameters, preserve zero-valued retry identifiers, and complete the View contract.
Diagram

graph TD
  G["Testing guidance"] --> T["Framework tests"] --> D["Double collaborators"]
  T --> I["Integration tests"] --> R["Real services"]
  T --> C["View contract"]
  I --> F["Production fixes"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Retain direct Mockery tests
  • ➕ Smaller migration and closer resemblance to some upstream tests.
  • ➖ Preserves inconsistent test-double conventions and implementation-coupled assertions.
2. Convert every test to an integration test
  • ➕ Maximizes observable-behavior coverage.
  • ➖ Requires more infrastructure and makes focused failure diagnosis harder.

Recommendation: Keep the PR's mixed approach: use Double at genuine collaborator boundaries and integration tests where real behavior matters. Retaining Mockery-backed framework APIs and upstream PHPUnit doubles avoids unnecessary compatibility work. Review the moved coverage by subsystem to ensure distinct assertions survive consolidation.

Files changed (225) +13002 / -14381

Bug fix (4) +18 / -4
View.phpDeclare effective rendering data on View +8/-0

Declare effective rendering data on View

• Adds gatherData(): array so response assertions can inspect shared and view-local data through the contract.

src/contracts/src/View/View.php

SesV2Transport.phpOmit unsupported SES v1 Source field +2/-1

Omit unsupported SES v1 Source field

• Stops sending Source to the SES v2 API while leaving raw sender headers and explicit options intact.

src/mail/src/Transport/SesV2Transport.php

RetryBatchCommand.phpPreserve zero-valued batch job IDs +2/-1

Preserve zero-valued batch job IDs

• Filters only empty identifiers instead of dropping the valid ID 0.

src/queue/src/Console/RetryBatchCommand.php

RetryCommand.phpPreserve zero-valued queue names and job IDs +6/-2

Preserve zero-valued queue names and job IDs

• Distinguishes omitted queue options from queue 0 and retains nonempty zero identifiers.

src/queue/src/Console/RetryCommand.php

Tests (215) +12938 / -14340
AuthDatabaseUserProviderTest.phpConvert database user provider collaborators +45/-42

Convert database user provider collaborators

• Uses Double expectations for provider interactions.

tests/Auth/AuthDatabaseUserProviderTest.php

AuthEloquentUserProviderTest.phpConvert Eloquent user provider collaborators +13/-11

Convert Eloquent user provider collaborators

• Replaces direct Mockery doubles while retaining provider assertions.

tests/Auth/AuthEloquentUserProviderTest.php

AuthGuardTest.phpRework guard tests around Double +279/-352

Rework guard tests around Double

• Converts extensive guard expectations and preserves authentication behavior checks.

tests/Auth/AuthGuardTest.php

AuthPasswordBrokerManagerTest.phpConvert password broker manager tests +51/-52

Convert password broker manager tests

• Uses Double for manager dependencies and verifies their interactions.

tests/Auth/AuthPasswordBrokerManagerTest.php

AuthPasswordBrokerTest.phpConvert password broker tests +67/-65

Convert password broker tests

• Moves broker collaborator expectations to Double.

tests/Auth/AuthPasswordBrokerTest.php

AuthTokenGuardTest.phpConvert token guard tests +92/-89

Convert token guard tests

• Replaces direct Mockery expectations with Double-backed guard assertions.

tests/Auth/AuthTokenGuardTest.php

AuthenticateMiddlewareTest.phpConvert authentication middleware collaborator +9/-6

Convert authentication middleware collaborator

• Uses Double to check middleware interactions.

tests/Auth/AuthenticateMiddlewareTest.php

Ably2BroadcasterTest.phpConvert Ably 2 broadcaster collaborator +10/-9

Convert Ably 2 broadcaster collaborator

• Uses Double for the broadcaster dependency.

tests/Broadcasting/Ably2BroadcasterTest.php

AblyBroadcasterTest.phpConvert Ably broadcaster expectations +47/-35

Convert Ably broadcaster expectations

• Checks Ably broadcasting through Double collaborators.

tests/Broadcasting/AblyBroadcasterTest.php

BroadcastEventTest.phpConvert broadcast event tests +33/-25

Convert broadcast event tests

• Replaces direct mocks in event dispatch assertions.

tests/Broadcasting/BroadcastEventTest.php

BroadcasterTest.phpConvert broadcaster base tests +70/-72

Convert broadcaster base tests

• Updates broadcaster collaborator expectations to Double.

tests/Broadcasting/BroadcasterTest.php

MercureBroadcasterTest.phpConvert Mercure broadcaster tests +81/-56

Convert Mercure broadcaster tests

• Uses Double to verify Mercure publishing behavior.

tests/Broadcasting/MercureBroadcasterTest.php

PusherBroadcasterTest.phpConvert Pusher broadcaster tests +65/-56

Convert Pusher broadcaster tests

• Moves Pusher collaborator assertions to Double.

tests/Broadcasting/PusherBroadcasterTest.php

RedisBroadcasterTest.phpConvert Redis broadcaster tests +89/-68

Convert Redis broadcaster tests

• Replaces direct Mockery collaborators in publish and channel checks.

tests/Broadcasting/RedisBroadcasterTest.php

BusBatchTest.phpConvert batch tests to Double +81/-70

Convert batch tests to Double

• Preserves batch state and callback checks with converted collaborators.

tests/Bus/BusBatchTest.php

BusBatchableTest.phpConvert batchable job tests +10/-7

Convert batchable job tests

• Uses Double in batchable-job interaction checks.

tests/Bus/BusBatchableTest.php

BusDispatcherTest.phpConvert bus dispatcher tests +28/-24

Convert bus dispatcher tests

• Verifies dispatch collaborators through Double.

tests/Bus/BusDispatcherTest.php

BusPendingBatchTest.phpConvert pending batch tests +76/-69

Convert pending batch tests

• Updates pending-batch expectations to Double.

tests/Bus/BusPendingBatchTest.php

BusPendingDispatchTest.phpConvert pending dispatch tests +66/-43

Convert pending dispatch tests

• Reworks dispatch collaborators and verification using Double.

tests/Bus/BusPendingDispatchTest.php

CacheDatabaseStoreTest.phpRework database cache store coverage +107/-148

Rework database cache store coverage

• Reduces implementation mocking while retaining database store behavior assertions.

tests/Cache/CacheDatabaseStoreTest.php

CacheEventsTest.phpConvert cache event tests +39/-36

Convert cache event tests

• Uses Double to check cache event dispatch.

tests/Cache/CacheEventsTest.php

CacheFailoverStoreTest.phpConvert cache failover tests +121/-116

Convert cache failover tests

• Uses Double collaborators to verify fallback and failure behavior.

tests/Cache/CacheFailoverStoreTest.php

CacheFileStoreTest.phpConvert file cache store collaborators +21/-15

Convert file cache store collaborators

• Replaces direct mocks in file store checks.

tests/Cache/CacheFileStoreTest.php

CacheManagerTest.phpConvert cache manager tests +44/-62

Convert cache manager tests

• Reworks manager collaborator assertions around Double.

tests/Cache/CacheManagerTest.php

CacheRedisStoreTest.phpMove Redis behavior to integration coverage +12/-247

Move Redis behavior to integration coverage

• Removes mock-heavy Redis store cases now exercised against Redis; keeps focused unit coverage.

tests/Cache/CacheRedisStoreTest.php

CacheRepositoryTest.phpConvert cache repository tests +240/-236

Convert cache repository tests

• Migrates repository store and event expectations to Double.

tests/Cache/CacheRepositoryTest.php

ClearCommandTest.phpConvert cache clear command tests +78/-53

Convert cache clear command tests

• Verifies command interactions through Double.

tests/Cache/ClearCommandTest.php

PutManyTest.phpAdjust Redis put-many assertion +1/-1

Adjust Redis put-many assertion

• Updates an operation test for the converted Redis coverage.

tests/Cache/Redis/Operations/PutManyTest.php

RedisStoreTest.phpExpand focused Redis store coverage +42/-13

Expand focused Redis store coverage

• Adds assertions around Redis store operations alongside the broader integration tests.

tests/Cache/Redis/RedisStoreTest.php

CacheCommandMutexTest.phpConvert cache-backed mutex tests +29/-33

Convert cache-backed mutex tests

• Checks mutex interactions with Double collaborators.

tests/Console/CacheCommandMutexTest.php

CommandMutexTest.phpConvert command mutex tests +26/-21

Convert command mutex tests

• Replaces direct mocks while retaining mutex lifecycle checks.

tests/Console/CommandMutexTest.php

CommandTest.phpConvert command tests +43/-41

Convert command tests

• Uses Double for command dependencies and invocation checks.

tests/Console/CommandTest.php

ConsoleApplicationTest.phpConvert console application collaborator +10/-5

Convert console application collaborator

• Updates application-level test expectations.

tests/Console/ConsoleApplicationTest.php

EventTest.phpConvert scheduled event tests +140/-141

Convert scheduled event tests

• Migrates scheduler collaborator expectations to Double.

tests/Console/Scheduling/EventTest.php

ScheduleTest.phpConvert schedule tests +38/-39

Convert schedule tests

• Uses Double to verify schedule interactions.

tests/Console/Scheduling/ScheduleTest.php

ContextualAttributeBindingTest.phpConvert contextual binding tests +80/-77

Convert contextual binding tests

• Replaces direct Mockery collaborators in attribute-driven container resolution checks.

tests/Container/ContextualAttributeBindingTest.php

DatabaseConcernsHasAttributesTest.phpSimplify attribute concern tests +6/-11

Simplify attribute concern tests

• Removes mock-specific setup from attribute behavior checks.

tests/Database/DatabaseConcernsHasAttributesTest.php

DatabaseConcernsPreventsCircularRecursionTest.phpSimplify recursion concern tests +4/-14

Simplify recursion concern tests

• Drops unnecessary mock-dependent coverage while retaining recursion assertions.

tests/Database/DatabaseConcernsPreventsCircularRecursionTest.php

DatabaseConnectionFactoryTest.phpConvert connection factory tests +20/-15

Convert connection factory tests

• Uses Double for database factory collaborators.

tests/Database/DatabaseConnectionFactoryTest.php

DatabaseConnectionTest.phpConvert database connection tests +245/-213

Convert database connection tests

• Reworks connection expectations, including ownership and query behavior, with Double.

tests/Database/DatabaseConnectionTest.php

DatabaseConnectorTest.phpConvert database connector tests +41/-38

Convert database connector tests

• Checks connector interactions through native-typed Double collaborators.

tests/Database/DatabaseConnectorTest.php

DatabaseEloquentAsVectorCastTest.phpConvert vector cast collaborator +8/-5

Convert vector cast collaborator

• Updates vector cast test setup to Double.

tests/Database/DatabaseEloquentAsVectorCastTest.php

DatabaseEloquentBelongsToManyCreateOrFirstTest.phpRework belongs-to-many create-or-first coverage +216/-404

Rework belongs-to-many create-or-first coverage

• Replaces mock-heavy relation cases with real database behavior and focused assertions.

tests/Database/DatabaseEloquentBelongsToManyCreateOrFirstTest.php

DatabaseEloquentBelongsToManyWithCastedAttributesTest.phpConsolidate casted pivot attribute coverage +0/-121

Consolidate casted pivot attribute coverage

• Removes duplicate mock-based relation assertions covered by database integration tests.

tests/Database/DatabaseEloquentBelongsToManyWithCastedAttributesTest.php

DatabaseEloquentBelongsToManyWithDefaultAttributesTest.phpConsolidate default pivot attribute coverage +0/-83

Consolidate default pivot attribute coverage

• Removes mock-based cases in favor of real relation coverage.

tests/Database/DatabaseEloquentBelongsToManyWithDefaultAttributesTest.php

DatabaseEloquentBelongsToTest.phpConvert belongs-to relation tests +25/-22

Convert belongs-to relation tests

• Replaces direct relation mocks with Double where a collaborator remains necessary.

tests/Database/DatabaseEloquentBelongsToTest.php

DatabaseEloquentBuilderCreateOrFirstTest.phpRework builder create-or-first coverage +225/-523

Rework builder create-or-first coverage

• Moves mock-heavy create-or-first scenarios toward real database assertions.

tests/Database/DatabaseEloquentBuilderCreateOrFirstTest.php

DatabaseEloquentBuilderTest.phpRework Eloquent builder tests +355/-548

Rework Eloquent builder tests

• Converts remaining collaborators and consolidates behavior covered by integration tests.

tests/Database/DatabaseEloquentBuilderTest.php

DatabaseEloquentCollectionQueueableTest.phpConvert queueable collection tests +12/-13

Convert queueable collection tests

• Uses Double for collection queueable collaborator checks.

tests/Database/DatabaseEloquentCollectionQueueableTest.php

DatabaseEloquentCollectionTest.phpConvert Eloquent collection tests +22/-19

Convert Eloquent collection tests

• Replaces direct mocks in collection behavior checks.

tests/Database/DatabaseEloquentCollectionTest.php

DatabaseEloquentFactoryTest.phpConvert Eloquent factory tests +13/-10

Convert Eloquent factory tests

• Updates factory test collaborators to Double.

tests/Database/DatabaseEloquentFactoryTest.php

DatabaseEloquentHasManyCreateOrFirstTest.phpRework has-many create-or-first tests +219/-307

Rework has-many create-or-first tests

• Consolidates mocked relation paths into real-row tests and keeps focused unit checks.

tests/Database/DatabaseEloquentHasManyCreateOrFirstTest.php

DatabaseEloquentHasManyTest.phpConsolidate has-many behavior coverage +2/-62

Consolidate has-many behavior coverage

• Removes mock-dependent cases covered by database integration assertions.

tests/Database/DatabaseEloquentHasManyTest.php

DatabaseEloquentHasManyThroughCreateOrFirstTest.phpRework has-many-through creation tests +125/-283

Rework has-many-through creation tests

• Moves mock-heavy create-or-first coverage toward actual database behavior.

tests/Database/DatabaseEloquentHasManyThroughCreateOrFirstTest.php

DatabaseEloquentHasOneTest.phpConsolidate has-one default tests +6/-102

Consolidate has-one default tests

• Removes Mockery-based default-model cases now exercised through real relations.

tests/Database/DatabaseEloquentHasOneTest.php

DatabaseEloquentIntegrationTest.phpExpand real Eloquent relation coverage +719/-1

Expand real Eloquent relation coverage

• Adds substantial database-backed assertions for relation writes, defaults, casting, and related behavior formerly mocked in unit tests.

tests/Database/DatabaseEloquentIntegrationTest.php

DatabaseEloquentInverseRelationTest.phpConvert inverse relation tests +68/-64

Convert inverse relation tests

• Replaces direct mocks in inverse relationship assertions.

tests/Database/DatabaseEloquentInverseRelationTest.php

DatabaseEloquentModelTest.phpConsolidate model tests and convert doubles +127/-802

Consolidate model tests and convert doubles

• Removes obsolete or duplicated mock-heavy cases and converts remaining model collaborators.

tests/Database/DatabaseEloquentModelTest.php

DatabaseEloquentMorphTest.phpMove morph upsert behavior to integration tests +0/-53

Move morph upsert behavior to integration tests

• Removes an implementation-mocked upsert case covered with real morph relation writes.

tests/Database/DatabaseEloquentMorphTest.php

DatabaseEloquentMorphToManyTest.phpConsolidate morph-to-many tests +0/-164

Consolidate morph-to-many tests

• Removes mock-based relation assertions in favor of integration coverage.

tests/Database/DatabaseEloquentMorphToManyTest.php

DatabaseEloquentMorphToTest.phpConvert morph-to tests +33/-43

Convert morph-to tests

• Uses Double for remaining polymorphic relation collaborators.

tests/Database/DatabaseEloquentMorphToTest.php

DatabaseEloquentPivotTest.phpConvert pivot tests +31/-28

Convert pivot tests

• Migrates pivot collaborator expectations to Double.

tests/Database/DatabaseEloquentPivotTest.php

DatabaseEloquentPolymorphicRelationsIntegrationTest.phpExtend polymorphic relation integration assertions +8/-1

Extend polymorphic relation integration assertions

• Adds real-database coverage for a previously mocked relation behavior.

tests/Database/DatabaseEloquentPolymorphicRelationsIntegrationTest.php

DatabaseEloquentRelationshipsTest.phpStrengthen relationship assertions +20/-8

Strengthen relationship assertions

• Adds relation behavior checks while replacing mock-specific expectations.

tests/Database/DatabaseEloquentRelationshipsTest.php

DatabaseEloquentSoftDeletesIntegrationTest.phpExpand real soft-delete coverage +100/-17

Expand real soft-delete coverage

• Moves soft-delete scope and trait behavior from mocked unit paths to database-backed checks.

tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php

DatabaseManagerTest.phpConvert database manager tests +13/-6

Convert database manager tests

• Uses Double for manager dependencies.

tests/Database/DatabaseManagerTest.php

DatabaseMariaDbBuilderTest.phpConvert MariaDB builder tests +12/-9

Convert MariaDB builder tests

• Replaces direct mocks in builder assertions.

tests/Database/DatabaseMariaDbBuilderTest.php

DatabaseMariaDbQueryGrammarTest.phpConvert MariaDB query grammar tests +11/-8

Convert MariaDB query grammar tests

• Uses Double for query grammar collaborators.

tests/Database/DatabaseMariaDbQueryGrammarTest.php

DatabaseMariaDbSchemaBuilderTest.phpConvert MariaDB schema builder tests +15/-12

Convert MariaDB schema builder tests

• Updates schema builder expectations to Double.

tests/Database/DatabaseMariaDbSchemaBuilderTest.php

DatabaseMariaDbSchemaGrammarTest.phpConvert MariaDB schema grammar tests +62/-60

Convert MariaDB schema grammar tests

• Migrates grammar dependency assertions to Double.

tests/Database/DatabaseMariaDbSchemaGrammarTest.php

DatabaseMigrationCreatorTest.phpConvert migration creator tests +30/-27

Convert migration creator tests

• Checks migration creation collaborators with Double.

tests/Database/DatabaseMigrationCreatorTest.php

DatabaseMigrationInstallCommandTest.phpConvert migration install tests +16/-22

Convert migration install tests

• Reworks command collaborators without direct Mockery mocks.

tests/Database/DatabaseMigrationInstallCommandTest.php

DatabaseMigrationMakeCommandTest.phpConvert migration make tests +14/-16

Convert migration make tests

• Updates migration creation expectations to Double.

tests/Database/DatabaseMigrationMakeCommandTest.php

DatabaseMigrationMigrateCommandTest.phpConvert migrate command tests +86/-83

Convert migrate command tests

• Moves migrator and command dependency expectations to Double.

tests/Database/DatabaseMigrationMigrateCommandTest.php

DatabaseMigrationRefreshCommandTest.phpConvert refresh command tests +43/-74

Convert refresh command tests

• Simplifies migration refresh setup and replaces direct mocks.

tests/Database/DatabaseMigrationRefreshCommandTest.php

DatabaseMigrationRepositoryTest.phpConvert migration repository tests +44/-41

Convert migration repository tests

• Uses Double for repository database collaborators.

tests/Database/DatabaseMigrationRepositoryTest.php

DatabaseMigrationResetCommandTest.phpConvert reset command tests +17/-18

Convert reset command tests

• Verifies migration reset interactions with Double.

tests/Database/DatabaseMigrationResetCommandTest.php

DatabaseMigrationRollbackCommandTest.phpConvert rollback command tests +24/-26

Convert rollback command tests

• Updates migrator and command expectations to Double.

tests/Database/DatabaseMigrationRollbackCommandTest.php

DatabaseMigrationStatusCommandTest.phpRemove unnecessary status-command mutex mock +0/-5

Remove unnecessary status-command mutex mock

• Allows the command test fixture to use its normal mutex wiring.

tests/Database/DatabaseMigrationStatusCommandTest.php

DatabaseMigratorIntegrationTest.phpExtend migrator integration checks +8/-5

Extend migrator integration checks

• Adjusts database-backed migrator assertions.

tests/Database/DatabaseMigratorIntegrationTest.php

DatabaseMigratorTest.phpConvert migrator tests +64/-61

Convert migrator tests

• Migrates direct collaborator expectations to Double.

tests/Database/DatabaseMigratorTest.php

DatabaseMySQLSchemaBuilderTest.phpConvert MySQL schema builder tests +15/-12

Convert MySQL schema builder tests

• Uses Double for builder collaborators.

tests/Database/DatabaseMySQLSchemaBuilderTest.php

DatabaseMySqlBuilderTest.phpConvert MySQL builder tests +57/-56

Convert MySQL builder tests

• Updates MySQL builder expectations to Double.

tests/Database/DatabaseMySqlBuilderTest.php

DatabaseMySqlQueryGrammarTest.phpConvert MySQL query grammar tests +14/-11

Convert MySQL query grammar tests

• Replaces direct mock collaborators.

tests/Database/DatabaseMySqlQueryGrammarTest.php

DatabaseMySqlSchemaGrammarTest.phpConvert MySQL schema grammar tests +67/-66

Convert MySQL schema grammar tests

• Uses Double for schema grammar expectations.

tests/Database/DatabaseMySqlSchemaGrammarTest.php

DatabasePdoConnectionTest.phpConvert PDO connection tests +63/-48

Convert PDO connection tests

• Verifies connection and PDO behavior with native-typed Double collaborators.

tests/Database/DatabasePdoConnectionTest.php

DatabasePostgresBuilderTest.phpConvert PostgreSQL builder tests +171/-173

Convert PostgreSQL builder tests

• Reworks builder collaborator expectations around Double.

tests/Database/DatabasePostgresBuilderTest.php

DatabasePostgresQueryGrammarTest.phpConvert PostgreSQL query grammar tests +13/-10

Convert PostgreSQL query grammar tests

• Uses Double for grammar dependencies.

tests/Database/DatabasePostgresQueryGrammarTest.php

DatabasePostgresSchemaBuilderTest.phpConvert PostgreSQL schema builder tests +15/-12

Convert PostgreSQL schema builder tests

• Updates builder expectations to Double.

tests/Database/DatabasePostgresSchemaBuilderTest.php

DatabasePostgresSchemaGrammarTest.phpConvert PostgreSQL schema grammar tests +29/-25

Convert PostgreSQL schema grammar tests

• Replaces direct Mockery grammar collaborators.

tests/Database/DatabasePostgresSchemaGrammarTest.php

DatabaseProcessorTest.phpConvert database processor tests +13/-10

Convert database processor tests

• Uses Double for processor dependencies.

tests/Database/DatabaseProcessorTest.php

DatabaseQueryBuilderTest.phpConvert query builder tests +477/-401

Convert query builder tests

• Migrates extensive query collaborator expectations while preserving generated-query assertions.

tests/Database/DatabaseQueryBuilderTest.php

DatabaseQueryExceptionTest.phpStrengthen query exception tests +23/-8

Strengthen query exception tests

• Updates connection collaborators and exception assertions.

tests/Database/DatabaseQueryExceptionTest.php

DatabaseSQLiteSchemaGrammarTest.phpConvert SQLite schema grammar tests +37/-45

Convert SQLite schema grammar tests

• Reworks grammar setup and collaborator verification.

tests/Database/DatabaseSQLiteSchemaGrammarTest.php

DatabaseSchemaBlueprintTest.phpConvert schema blueprint tests +34/-34

Convert schema blueprint tests

• Checks blueprint operations with Double collaborators.

tests/Database/DatabaseSchemaBlueprintTest.php

DatabaseSchemaBuilderTest.phpConvert schema builder tests +101/-98

Convert schema builder tests

• Migrates builder connection expectations to Double.

tests/Database/DatabaseSchemaBuilderTest.php

DatabaseSeederTest.phpConvert seeder tests +21/-18

Convert seeder tests

• Updates seeder dependency expectations.

tests/Database/DatabaseSeederTest.php

DatabaseSoftDeletingScopeTest.phpConsolidate soft-delete scope coverage +0/-53

Consolidate soft-delete scope coverage

• Removes implementation-mocked scope checks now covered against actual rows.

tests/Database/DatabaseSoftDeletingScopeTest.php

DatabaseSoftDeletingTraitTest.phpConsolidate soft-delete trait coverage +0/-145

Consolidate soft-delete trait coverage

• Removes mock-based trait cases replaced by integration assertions.

tests/Database/DatabaseSoftDeletingTraitTest.php

DatabaseSqliteSchemaStateTest.phpConvert SQLite schema state tests +23/-19

Convert SQLite schema state tests

• Replaces direct mocks in schema dump and load checks.

tests/Database/DatabaseSqliteSchemaStateTest.php

DatabaseTransactionsTest.phpConvert transaction tests +31/-28

Convert transaction tests

• Uses Double for connection and transaction collaborator assertions.

tests/Database/DatabaseTransactionsTest.php

DatabaseWipeCommandTest.phpRemove unnecessary wipe-command mutex mock +0/-5

Remove unnecessary wipe-command mutex mock

• Lets the command fixture use normal mutex behavior.

tests/Database/DatabaseWipeCommandTest.php

MigratorTest.phpConvert additional migrator tests +41/-52

Convert additional migrator tests

• Replaces direct mocks in migration execution checks.

tests/Database/MigratorTest.php

PruneCommandTest.phpConvert prune command tests +12/-9

Convert prune command tests

• Uses Double for prune collaborators.

tests/Database/PruneCommandTest.php

SeedCommandTest.phpConvert seed command tests +44/-51

Convert seed command tests

• Updates seeding command dependencies and verification.

tests/Database/SeedCommandTest.php

BroadcastedEventsTest.phpConvert broadcast event tests +40/-25

Convert broadcast event tests

• Uses Double in event broadcasting assertions.

tests/Events/BroadcastedEventsTest.php

EventsSubscriberTest.phpConvert subscriber collaborator +7/-3

Convert subscriber collaborator

• Updates event subscriber interaction checks.

tests/Events/EventsSubscriberTest.php

QueuedEventsTest.phpConvert queued event tests +105/-96

Convert queued event tests

• Migrates queue and dispatcher expectations to Double.

tests/Events/QueuedEventsTest.php

FilesystemAdapterTest.phpConvert filesystem adapter tests +94/-77

Convert filesystem adapter tests

• Uses Double for storage adapter collaborators.

tests/Filesystem/FilesystemAdapterTest.php

FilesystemTest.phpConvert filesystem test collaborator +6/-3

Convert filesystem test collaborator

• Replaces a direct mock while retaining filesystem assertions.

tests/Filesystem/FilesystemTest.php

HandleExceptionsTest.phpConvert bootstrap exception tests +45/-37

Convert bootstrap exception tests

• Uses Double for exception bootstrap collaborators.

tests/Foundation/Bootstrap/HandleExceptionsTest.php

ListenerTest.phpConvert renderer listener tests +10/-7

Convert renderer listener tests

• Updates listener dependency expectations.

tests/Foundation/Exceptions/Renderer/ListenerTest.php

FoundationAuthenticationTest.phpConvert foundation authentication tests +18/-13

Convert foundation authentication tests

• Replaces direct authentication mocks with Double.

tests/Foundation/FoundationAuthenticationTest.php

FoundationCacheBasedMaintenanceModeTest.phpConvert cache maintenance tests +25/-23

Convert cache maintenance tests

• Uses Double for maintenance cache interactions.

tests/Foundation/FoundationCacheBasedMaintenanceModeTest.php

FoundationExceptionsHandlerTest.phpConvert exception handler tests +96/-81

Convert exception handler tests

• Migrates handler collaborator expectations to Double.

tests/Foundation/FoundationExceptionsHandlerTest.php

FoundationFormRequestTest.phpConvert form request tests +18/-15

Convert form request tests

• Updates request validation dependencies and assertions.

tests/Foundation/FoundationFormRequestTest.php

FoundationInteractsWithDatabaseTest.phpConvert database testing concern tests +67/-65

Convert database testing concern tests

• Checks database-testing helpers with Double collaborators.

tests/Foundation/FoundationInteractsWithDatabaseTest.php

InteractsWithDatabaseTest.phpConvert database assertion concern tests +11/-9

Convert database assertion concern tests

• Updates collaborator setup for database assertions.

tests/Foundation/Testing/Concerns/InteractsWithDatabaseTest.php

DatabaseTruncationTest.phpConvert database truncation tests +54/-51

Convert database truncation tests

• Uses Double to verify truncation and connection interactions.

tests/Foundation/Testing/DatabaseTruncationTest.php

LazilyRefreshDatabaseTest.phpConvert lazy refresh test collaborator +5/-3

Convert lazy refresh test collaborator

• Updates database refresh setup without direct Mockery.

tests/Foundation/Testing/LazilyRefreshDatabaseTest.php

HttpRedirectResponseTest.phpConvert redirect response collaborator +8/-5

Convert redirect response collaborator

• Replaces a direct mock in redirect assertions.

tests/Http/HttpRedirectResponseTest.php

HttpResponseTest.phpConvert HTTP response collaborator +6/-3

Convert HTTP response collaborator

• Updates response test setup and verification.

tests/Http/HttpResponseTest.php

JsonResourceTest.phpSimplify JSON resource tests +3/-5

Simplify JSON resource tests

• Removes mock-dependent resource setup.

tests/Http/JsonResourceTest.php

PreventRequestForgeryTest.phpSimplify request forgery test setup +2/-3

Simplify request forgery test setup

• Drops an unnecessary mock in middleware coverage.

tests/Http/Middleware/PreventRequestForgeryTest.php

ImageManagerTest.phpConvert image manager tests +48/-48

Convert image manager tests

• Migrates image driver collaborator expectations to Double.

tests/Image/ImageManagerTest.php

RedisStoreTest.phpExercise Redis cache behavior against Redis +137/-5

Exercise Redis cache behavior against Redis

• Adds real store operations, stale-tag scanning, and scan-prefix regression coverage previously represented by mocks.

tests/Integration/Cache/Redis/RedisStoreTest.php

DatabaseLockTest.phpConvert database lock integration collaborators +50/-46

Convert database lock integration collaborators

• Retains lock behavior and connection ownership checks with updated doubles.

tests/Integration/Database/DatabaseLockTest.php

ListenerTest.phpExtend listener integration coverage +11/-0

Extend listener integration coverage

• Adds assertions for event listener behavior.

tests/Integration/Events/ListenerTest.php

ConfigCacheCommandTest.phpConvert config cache integration collaborator +13/-9

Convert config cache integration collaborator

• Updates command checks without direct Mockery mocks.

tests/Integration/Foundation/Console/ConfigCacheCommandTest.php

EventCacheCommandTest.phpConvert event cache integration collaborator +13/-8

Convert event cache integration collaborator

• Updates event cache command expectations.

tests/Integration/Foundation/Console/EventCacheCommandTest.php

RouteCacheCommandTest.phpConvert route cache integration collaborator +13/-9

Convert route cache integration collaborator

• Updates route cache command expectations.

tests/Integration/Foundation/Console/RouteCacheCommandTest.php

MaintenanceModeTest.phpConvert maintenance mode integration tests +30/-26

Convert maintenance mode integration tests

• Retains maintenance behavior checks with Double collaborators.

tests/Integration/Foundation/MaintenanceModeTest.php

CallQueuedHandlerTest.phpConvert queued handler integration tests +62/-57

Convert queued handler integration tests

• Uses Double where external handler collaborators remain necessary.

<a href='http...

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Queue tests contaminate later payloads 🐞 Bug ☼ Reliability
Description
testPayloadHooksAreAppliedToTheQueuedPayload() registers two callbacks with
Queue::createPayloadUsing() but never clears them. Because the callback registry is static,
subsequent tests in the same process apply both callbacks to unrelated job payloads.
Code

tests/Integration/Queue/Redis/RedisQueueTest.php[R838-842]

+        Queue::createPayloadUsing(function (string $connection, ?string $queue, array $payload) use (&$receivedQueue): array {
+            $receivedQueue = $queue;
+
+            return ['custom' => 'taylor'];
+        });
Evidence
The new test registers callbacks without cleanup, while Queue stores them for the worker lifetime
and applies them to every subsequent payload.

tests/Integration/Queue/Redis/RedisQueueTest.php[831-859]
src/queue/src/Queue.php[398-426]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new Redis integration test leaves worker-wide payload callbacks registered after it finishes.
## Fix Focus Areas
- tests/Integration/Queue/Redis/RedisQueueTest.php[831-859]
## Recommended Fix
Clear the registered callbacks in a `finally` block around the test actions, including when an assertion or queue operation fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Missing-record fallbacks lose test coverage 🐞 Bug ⚙ Maintainability
Description
The replacement findOr case in testFindMethodsUseModelPrimaryKey() supplies an existing model
and no callback, while the separate fallback tests were removed. It therefore never exercises
missing scalar or collection IDs, a callback supplied as the columns argument, or the empty-ID
behavior implemented by Builder::findOr().
Code

tests/Database/DatabaseEloquentBuilderTest.php[L295-296]

-    public function testFindOrMethod(): void
-    {
Evidence
The changed shared case always returns its configured target. The removed tests covered callback
results for missing IDs, whereas the implementation has separate callback and collection paths.

tests/Database/DatabaseEloquentBuilderTest.php[69-81]
src/database/src/Eloquent/Builder.php[677-704]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The consolidated builder test covers only a successful `findOr` lookup and removes its callback and collection fallback cases.
## Fix Focus Areas
- tests/Database/DatabaseEloquentBuilderTest.php[69-81]
## Recommended Fix
Add focused cases for missing scalar and collection IDs, callback-as-columns handling, and empty IDs. Assert both the returned value and whether the callback runs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Missing route lookups can go unnoticed ✓ Resolved
Description
testRouteParameterCanExtractSupportedPropertyPaths() changes its missing and null route
lookups from required mock calls to lenient allows() stubs. If either lookup is skipped or uses an
unconfigured parameter, the double can return its default null and the corresponding final
assertion still passes.

View medium (1)
4. Unmatched relations lose an assertion ✓ Resolved
Description
testBelongsToManyMatchesStringablePivotKeysToTheirParents() checks that the unmatched parent's
friends collection is empty instead of checking that the relation remains unloaded. Accessing
friends can lazy-load an empty collection even if match() incorrectly marked that non-null,
unmatched parent as loaded, so the replacement misses the distinction asserted by the deleted test.


Informational

5. Attaching with pivot defaults no longer checks parent touch 🐞 Bug ⚙ Maintainability
Description
The deleted testWithPivotValueMethodSetsDefaultArgumentsForInsertion expected attach() on a
withPivotValue(...) relation to call touchIfTouching() exactly once, but the replacement in
DatabaseEloquentIntegrationTest only checks the inserted pivot default and filtered retrieval. If
the attach() path stopped touching parent timestamps, no remaining test would fail, despite the
PR's claim that no distinct assertions were lost.
Code

tests/Database/DatabaseEloquentIntegrationTest.php[R507-510]

+        $relation = $user->friends()->withPivotValue(['friend_level_id' => 1]);
+
+        $relation->attach($friend);
+        $user->friends()->attach($other, ['friend_level_id' => 2]);
Evidence
The removed default-attributes test asserted the touch call. The consolidated integration test at
lines 502-514 asserts only pivot contents. The other touch tests cover explicit relation touching
and sync, not withPivotValue()->attach(). The same consolidation also replaced
assertNull($models[1]->foo) for an unmatched parent with assertCount(0, ...), so nothing checks
any more that an unmatched parent's relation stays unloaded.

tests/Database/DatabaseEloquentIntegrationTest.php[502-514]
tests/Database/DatabaseEloquentBelongsToManyWithoutTouchingTest.php[43-56]
src/database/src/Eloquent/Relations/BelongsToMany.php[250-278]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
When the BelongsToMany default-attributes test was folded into the integration test, the old check that `attach()` through `withPivotValue()` touches the parent (`touchIfTouching`) was dropped.
## Fix Focus Areas
- tests/Database/DatabaseEloquentIntegrationTest.php[502-514]
## Recommended Fix
Give the related model a `$touches` relation, or use a relation that touches its parent. Then, in the `withPivotValue` integration test, assert that the parent's `updated_at` changes after `attach()`. Alternatively, keep a small focused test that spies on `touchIfTouching()` for this path. Also add an assertion that an unmatched parent's relation stays unloaded or null after `match()`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge, with both previous findings addressed and no new actionable issues found.

Summary

Adopts Double across core framework tests and replaces selected mocks with real database, Redis, HTTP, session, and SDK behavior.

  • Core framework tests use Double for their direct collaborators.
  • Framework tests exercise real database, Redis, and session behavior.
  • View implementations provide the data used by response assertions.
  • SES v2 requests leave out the v1-only Source field.
  • Queue retry commands keep the valid value "0".

Both previous findings are addressed. No new actionable issues were found in the changes since the previous review. This review used source inspection; tests were not run.

Reviews (2) · Last reviewed commit: "test: retain behavioral coverage after D..." · Reviewed by Greptile

Comment thread tests/Queue/QueueSqsQueueTest.php Resolved
Exercise translation registration both before and after translator resolution, and verify that changing a password during an authenticated request refreshes the stored session hash.

Validate serialized SQS command names and restored job types, with a concrete message-group state assertion. Require the nullable route lookups so lenient defaults cannot hide a wrong parameter, and inspect unmatched relationship state without lazy-loading it.

Make the existing attach-touch test distinguish creation and attachment timestamps. Clarify that backdated Redis membership scores isolate expiry pruning from orphan cleanup rather than adding duplicate scan instrumentation.

Validation: all seven changed test classes pass, including isolated Redis integration coverage. Formatting and whitespace checks pass; production code is unchanged.
@binaryfire

Copy link
Copy Markdown
Member Author

The five Qodo findings have been checked:

  1. Payload callback cleanup is already owned by AfterEachTestSubscriber, which calls Queue::flushState() between tests, including failures. No duplicate reset was added.
  2. The findOr fallback cases remain in DatabaseEloquentIntegrationTest::testFindOrReturnsTheModelOrTheCallbackResult and testFindOrWithManyIdentifiersReturnsACollection, covering scalar, array and Collection IDs, callback-as-columns, selected columns and empty IDs.
  3. The missing/null route lookups now require their exact arguments, so a lenient default cannot conceal the wrong lookup.
  4. The unmatched pivot parent now asserts that friends remains unloaded, without triggering a lazy query.
  5. Pivot-default insertion and filtering remain covered. The general attach-touch test now creates at one time, attaches at a later time and verifies the parent's exact updated timestamp. Pivot defaults do not select the touch path, so they were not added to that separate test.

@binaryfire
binaryfire merged commit 9fe98df into 0.4 Nov 16, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant