From 40dab36417eae1ed24b62c16fb06631b39d715d3 Mon Sep 17 00:00:00 2001 From: Joey Smith Date: Sun, 9 Aug 2026 20:23:02 -0500 Subject: [PATCH] test: fix invalid code coverage target attributes Several test classes' #[CoversClass]/#[CoversMethod] attributes pointed at interfaces (ConnectionInterface, AdapterInterface, SchemaAwareInterface, PdoConnectionInterface) instead of the concrete classes actually executed. Interfaces have no executable code, so PHPUnit rejects them as coverage targets once a coverage driver (PCOV/Xdebug) is active - previously invisible because coverage was never enabled for these tests before this migration. Also fixes two unrelated but same-symptom issues found while verifying: - DriverTest referenced a getDatabasePlatformName method that does not exist anywhere in this codebase or its php-db/phpdb dependency (stale reference, removed) - ConnectionTransactionsTest's CoversMethod targets included a trailing '()' in the method name string (e.g. 'beginTransaction()'), which PHPUnit does not strip No behavior changes - test bodies are untouched, only coverage-attribution metadata. Verified locally: XDEBUG_MODE=coverage vendor/bin/phpunit now runs the full unit suite clean (90 tests, 204 assertions, no warnings). --- test/integration/Pdo/AbstractAdapterTestCase.php | 10 +++++----- test/integration/Pdo/ConnectionTest.php | 7 +++---- test/integration/Pdo/TableGatewayAndAdapterTest.php | 4 ++-- test/unit/Pdo/ConnectionTest.php | 2 -- test/unit/Pdo/ConnectionTransactionsTest.php | 8 ++++---- test/unit/Pdo/DriverTest.php | 1 - 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/test/integration/Pdo/AbstractAdapterTestCase.php b/test/integration/Pdo/AbstractAdapterTestCase.php index a528e9e..586b066 100644 --- a/test/integration/Pdo/AbstractAdapterTestCase.php +++ b/test/integration/Pdo/AbstractAdapterTestCase.php @@ -8,17 +8,17 @@ use PhpDb\Adapter\AdapterInterface; use PhpDb\Adapter\Driver\ConnectionInterface; use PhpDb\Adapter\SchemaAwareInterface; +use PhpDb\Mysql\Pdo\Connection; use PhpDb\Mysql\Pdo\Driver; use PhpDbIntegrationTest\Mysql\Container\TestAsset\SetupTrait; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\TestCase; #[CoversMethod(Adapter::class, 'getCurrentSchema')] -#[CoversMethod(AdapterInterface::class, '__construct')] -#[CoversMethod(SchemaAwareInterface::class, 'getCurrentSchema')] -#[CoversMethod(ConnectionInterface::class, 'connect')] -#[CoversMethod(ConnectionInterface::class, 'disconnect')] -#[CoversMethod(ConnectionInterface::class, 'isConnected')] +#[CoversMethod(Adapter::class, '__construct')] +#[CoversMethod(Connection::class, 'connect')] +#[CoversMethod(Connection::class, 'disconnect')] +#[CoversMethod(Connection::class, 'isConnected')] abstract class AbstractAdapterTestCase extends TestCase { use SetupTrait; diff --git a/test/integration/Pdo/ConnectionTest.php b/test/integration/Pdo/ConnectionTest.php index 1947365..3ec97c1 100644 --- a/test/integration/Pdo/ConnectionTest.php +++ b/test/integration/Pdo/ConnectionTest.php @@ -24,10 +24,9 @@ #[Group('integration-pdo')] #[CoversClass(Connection::class)] #[CoversMethod(Connection::class, 'prepare')] -#[CoversClass(ConnectionInterface::class)] -#[CoversMethod(ConnectionInterface::class, 'execute')] -#[CoversMethod(ConnectionInterface::class, 'getResource')] -#[CoversMethod(ConnectionInterface::class, 'getLastGeneratedValue')] +#[CoversMethod(Connection::class, 'execute')] +#[CoversMethod(Connection::class, 'getResource')] +#[CoversMethod(Connection::class, 'getLastGeneratedValue')] final class ConnectionTest extends TestCase { use SetupTrait; diff --git a/test/integration/Pdo/TableGatewayAndAdapterTest.php b/test/integration/Pdo/TableGatewayAndAdapterTest.php index 690c959..79ef480 100644 --- a/test/integration/Pdo/TableGatewayAndAdapterTest.php +++ b/test/integration/Pdo/TableGatewayAndAdapterTest.php @@ -5,7 +5,7 @@ namespace PhpDbIntegrationTest\Mysql\Pdo; use Exception; -use PhpDb\Adapter\Driver\ConnectionInterface; +use PhpDb\Mysql\Pdo\Connection; use PhpDb\ResultSet\AbstractResultSet; use PhpDb\TableGateway\TableGateway; use PhpDbIntegrationTest\Mysql\Container\TestAsset\SetupTrait; @@ -21,7 +21,7 @@ * On tear down disconnected from the database and set the driver adapter on null * Running many tests ended up in consuming all mysql connections and not releasing them */ -#[CoversMethod(ConnectionInterface::class, 'disconnect')] +#[CoversMethod(Connection::class, 'disconnect')] final class TableGatewayAndAdapterTest extends TestCase { use SetupTrait; diff --git a/test/unit/Pdo/ConnectionTest.php b/test/unit/Pdo/ConnectionTest.php index 036f96e..61be739 100644 --- a/test/unit/Pdo/ConnectionTest.php +++ b/test/unit/Pdo/ConnectionTest.php @@ -6,7 +6,6 @@ use Exception; use Override; -use PhpDb\Adapter\Driver\PdoConnectionInterface; use PhpDb\Adapter\Exception\InvalidConnectionParametersException; use PhpDb\Adapter\Exception\RuntimeException; use PhpDb\Mysql\Pdo\Connection; @@ -16,7 +15,6 @@ #[CoversMethod(Connection::class, 'getResource')] #[CoversMethod(Connection::class, 'getDsn')] -#[CoversMethod(PdoConnectionInterface::class, 'getDsn')] final class ConnectionTest extends TestCase { protected Connection $connection; diff --git a/test/unit/Pdo/ConnectionTransactionsTest.php b/test/unit/Pdo/ConnectionTransactionsTest.php index 38fd598..d09db25 100644 --- a/test/unit/Pdo/ConnectionTransactionsTest.php +++ b/test/unit/Pdo/ConnectionTransactionsTest.php @@ -18,10 +18,10 @@ */ #[CoversClass(Connection::class)] #[CoversClass(AbstractConnection::class)] -#[CoversMethod(Connection::class, 'beginTransaction()')] -#[CoversMethod(Connection::class, 'inTransaction()')] -#[CoversMethod(Connection::class, 'commit()')] -#[CoversMethod(Connection::class, 'rollback()')] +#[CoversMethod(Connection::class, 'beginTransaction')] +#[CoversMethod(Connection::class, 'inTransaction')] +#[CoversMethod(Connection::class, 'commit')] +#[CoversMethod(Connection::class, 'rollback')] final class ConnectionTransactionsTest extends TestCase { protected ConnectionWrapper $wrapper; diff --git a/test/unit/Pdo/DriverTest.php b/test/unit/Pdo/DriverTest.php index 435ee94..fe8e188 100644 --- a/test/unit/Pdo/DriverTest.php +++ b/test/unit/Pdo/DriverTest.php @@ -16,7 +16,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -#[CoversMethod(Driver::class, 'getDatabasePlatformName')] #[CoversMethod(Driver::class, 'getResultPrototype')] #[CoversMethod(Driver::class, 'createResult')] final class DriverTest extends TestCase