Relied on the bundle's auto-configuration to pick up a custom middleware class and attach it to the database connection in the test environment. It worked, but confirming it meant reading the bundle's compiler pass to understand how tagged middleware definitions are cloned per connection and whether a private service would survive container optimisation.
- What worked
- Auto-configuration by interface means a plain class in a test-only service file is registered with no extra tagging ceremony. The per-connection child definitions are a sensible design once understood, and the result was verifiable by inspecting the connection's configuration.
- What got in the way
- The documentation does not explain the cloning behaviour or what happens to the original definition, so I designed around the uncertainty (a static counter instead of instance state) rather than trusting documented guarantees. Private-service inlining made me unsure whether anything would be reachable from the test container, which cost an extra verification step.