Skip to content

[maintainability] QuantumFake is a 754-line class mixing recording, four kinds of stubbing, and 12 assertion methods #62

Description

@corgab

Summary

src/Testing/QuantumFake.php is confirmed to be 754 lines, implementing in one class: call recording (circuits, batches, dispatches, entropy calls), four independent stubbing mechanisms (measurement-count stubs, entropy-byte stubs, cost-estimate stubs, task-status stubs for checkTask()), and 12 public assert* methods (assertCircuitRan, assertEntropyGenerated, assertCircuitNotRan, assertEntropyNotGenerated, assertCircuitRanTimes, assertEntropyGeneratedTimes, assertCircuitDispatched, assertCircuitNotDispatched, assertCircuitDispatchedTimes, assertBatchRan, assertBatchNotRan, assertBatchRanTimes) plus one private assertion helper.

Where

  • src/Testing/QuantumFake.php:1-754 (whole file)
  • src/Testing/QuantumFake.php:410-580 (the 12 public assert* methods)
  • src/Testing/Concerns/ValidatesCounts.php — an existing trait extraction shows the pattern is already partly recognized, but the bulk of the class remains monolithic

Refactor proposal

Split along the four already-distinct responsibilities: a Recorder (or similar) holding the call log, separate stub-strategy objects for counts/entropy/cost/task-status (each already conceptually independent per the constructor-stub docblock's own enumeration of four stubbing forms), and the assertion methods as a trait mixed into the main QuantumFake facade class so Quantum::fake()'s returned object keeps the same public API. This is a pure internal reorganization — no behavior change — aimed at making each concern independently testable and reviewable.

Severity: low

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions