Achieve 100% test coverage for Adapter/* classes#2
Closed
simon-mundy wants to merge 1 commit into
Closed
Conversation
Add targeted tests and fix coverage attribution to close the remaining 29 uncovered lines across Adapter/*. New test assets: - TestConnection: extends AbstractConnection directly (not via AbstractPdoConnection) to test inherited methods like setConnectionParameters() and getResource() auto-connect - TestPlatform: extends AbstractPlatform without overriding quoteValue(), allowing direct coverage of the base class throw/escape paths Test changes: - AbstractConnectionTest: switch from ConnectionWrapper (which goes through AbstractPdoConnection overrides) to TestConnection so AbstractConnection methods are exercised directly - PdoTest: add missing #[CoversMethod] for formatParameterName, fix phpstan method.resultUnused warning - StatementTest: add double-execute test (bindParametersFromContainer early-return path) and clone-with-container test - Sql92Test: add tests for AbstractPlatform::quoteValue() throw and escape paths via TestPlatform - ProfilerTest: split combined test into separate string/container tests, remove dead TypeError assertion (covered by union type) - ParameterContainerTest: remove stale @PHPStan-Ignore Config: - phpunit.xml.dist: re-enable AdapterAwareTraitTest (the test works, the exclusion was a leftover)
simon-mundy
marked this pull request as draft
March 25, 2026 09:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the remaining 29 uncovered lines across Adapter/* by adding targeted tests, fixing coverage attribution, and introducing two new test assets. Brings Adapter/* from 93% to 100% line coverage.
Root causes of the gaps
The uncovered lines fell into three categories:
Wrong test asset hierarchy —
AbstractConnectionTestusedConnectionWrapperwhich extendsAbstractPdoConnection. SinceAbstractPdoConnectionoverridessetConnectionParameters()and provides its ownisConnected(), the inheritedAbstractConnectionmethods were never exercised.Missing
#[CoversMethod]attribution —PdoTesttestedformatParameterName()extensively via data providers but didn't declare#[CoversMethod(AbstractPdo::class, 'formatParameterName')], so 16 lines of coverage weren't credited.Untested code paths —
Statement::bindParametersFromContainer()early-return when already bound (requires double-execute),Statement::__clone()with a non-null ParameterContainer, andAbstractPlatform::quoteValue()which was always tested throughSql92(which overrides it).New test assets
TestConnection(test/unit/Adapter/Driver/TestAsset/) — ExtendsAbstractConnectiondirectly, not throughAbstractPdoConnection. Provides a resource-basedisConnected()sodisconnect()andgetResource()auto-connect work correctly against the base class.TestPlatform(test/unit/Adapter/Platform/TestAsset/) — ExtendsAbstractPlatformwithout overridingquoteValue(), allowing direct coverage of the base class throw (no driver) and escape (with driver) paths.Test changes
AbstractConnectionTestConnectionWrappertoTestConnectionsoAbstractConnection::setConnectionParameters(),getResource()auto-connect, andgetDriverName()are exercised directlyPdoTest#[CoversMethod]forformatParameterName; added@phpstan-ignoreformethod.resultUnusedon expected-throw testStatementTesttestSecondExecuteSkipsBindingWhenAlreadyBound(double-execute covers theparametersBoundearly return) andtestCloneClonesParameterContainerWhenSetSql92TesttestAbstractPlatformQuoteValueThrowsWithoutDriverandtestAbstractPlatformQuoteValueEscapesWithDriverviaTestPlatformProfilerTesttestProfilerStartintotestProfilerStartWithStringandtestProfilerStartWithStatementContainer; removed deadTypeErrorassertion (union type covers it)ParameterContainerTest@phpstan-ignore argument.type(method acceptsmixed)phpunit.xml.distAdapterAwareTraitTest— the test works correctly, the exclusion was a leftoverTest plan
./vendor/bin/phpunit— 1446 tests pass, 0 failures./vendor/bin/phpstan— 0 errors./vendor/bin/phpcs— no new violationsXDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text— Adapter/* shows 100%