From 893bc205c4253bc560b3e897126034798deb8b49 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 25 Feb 2021 17:23:20 +0100 Subject: [PATCH] Improve code coverage to satisfy Codecov With the introduction of PHP8 compatibility, some `class_alias` code has been introduced. We have not been able to make PHPUnit grok the coverage of this code by other means. Additionally, some annotations have been added to improve code coverage metrics on code which actually has been covered but was not accounted. --- codecov.yml | 1 + src/Crate/PDO/PDOImplementation.php | 2 ++ src/Crate/PDO/PDOInterface.php | 2 ++ test/CrateTest/PDO/PDOStatementTest.php | 7 +++++++ test/CrateTest/PDO/PDOTest.php | 1 + 5 files changed, 13 insertions(+) diff --git a/codecov.yml b/codecov.yml index b9b686e..8b485e7 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,4 +1,5 @@ # https://docs.codecov.io/docs/common-recipe-list +# https://docs.codecov.io/docs/commit-status#patch-status coverage: status: diff --git a/src/Crate/PDO/PDOImplementation.php b/src/Crate/PDO/PDOImplementation.php index 004b919..6c42a4c 100644 --- a/src/Crate/PDO/PDOImplementation.php +++ b/src/Crate/PDO/PDOImplementation.php @@ -40,8 +40,10 @@ use const PHP_VERSION_ID; +// @codeCoverageIgnoreStart if (PHP_VERSION_ID >= 80000) { class_alias('\Crate\PDO\PDOImplementationPhp8', '\Crate\PDO\PDOImplementation'); } else { class_alias('\Crate\PDO\PDOImplementationPhp7', '\Crate\PDO\PDOImplementation'); } +// @codeCoverageIgnoreEnd diff --git a/src/Crate/PDO/PDOInterface.php b/src/Crate/PDO/PDOInterface.php index b822a71..66e4e93 100644 --- a/src/Crate/PDO/PDOInterface.php +++ b/src/Crate/PDO/PDOInterface.php @@ -47,8 +47,10 @@ * * @internal */ +// @codeCoverageIgnoreStart if (PHP_VERSION_ID >= 80000) { class_alias('\Crate\PDO\PDOInterfacePhp8', '\Crate\PDO\PDOInterface'); } else { class_alias('\Crate\PDO\PDOInterfacePhp7', '\Crate\PDO\PDOInterface'); } +// @codeCoverageIgnoreEnd diff --git a/test/CrateTest/PDO/PDOStatementTest.php b/test/CrateTest/PDO/PDOStatementTest.php index 518bebd..19b9a1d 100644 --- a/test/CrateTest/PDO/PDOStatementTest.php +++ b/test/CrateTest/PDO/PDOStatementTest.php @@ -357,6 +357,7 @@ public function testRowCount() /** * @covers ::fetchColumn + * @covers \Crate\PDO\Exception\InvalidArgumentException */ public function testFetchColumnWithInvalidColumnNumberType() { @@ -565,6 +566,7 @@ public function testFetchAll($fetchStyle, array $expected) /** * @covers ::fetchAll * @covers ::doFetchAll + * @covers \Crate\PDO\Exception\InvalidArgumentException */ public function testFetchAllWithFetchStyleFuncAndInvalidCallback() { @@ -606,6 +608,7 @@ public function testFetchAllWithFetchStyleFunc() /** * @covers ::fetchAll * @covers ::doFetchAll + * @covers \Crate\PDO\Exception\InvalidArgumentException */ public function testFetchAllWithFetchStyleColumnAndInvalidColumnIndexType() { @@ -741,6 +744,7 @@ public function testGetColumnMeta() /** * @covers ::setFetchMode * @covers ::doSetFetchMode + * @covers \Crate\PDO\Exception\InvalidArgumentException */ public function testSetFetchModeWithColumnAndMissingColNo() { @@ -755,6 +759,7 @@ public function testSetFetchModeWithColumnAndMissingColNo() /** * @covers ::setFetchMode * @covers ::doSetFetchMode + * @covers \Crate\PDO\Exception\InvalidArgumentException */ public function testSetFetchModeWithColumnAndInvalidColNo() { @@ -830,6 +835,8 @@ public function testSetFetchModeWithInvalidFetchStyle() /** * @covers ::setFetchMode * @covers ::doSetFetchMode + * @covers \Crate\PDO\Exception\InvalidArgumentException + * * @dataProvider fetchModeStyleProvider * * @param int $fetchStyle diff --git a/test/CrateTest/PDO/PDOTest.php b/test/CrateTest/PDO/PDOTest.php index a7c0ec8..366d2d8 100644 --- a/test/CrateTest/PDO/PDOTest.php +++ b/test/CrateTest/PDO/PDOTest.php @@ -315,6 +315,7 @@ public function testLastInsertIdThrowsUnsupportedException() * Not all things have been implemented yet. * * @requires PHP >= 8 + * @covers ::query * * @dataProvider fetchModeStyleProvider * @param $fetchMode