Skip to content

Commit

Permalink
Improve code coverage to satisfy Codecov
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amotl committed Feb 25, 2021
1 parent cefb5e3 commit 4445a25
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# https://docs.codecov.io/docs/common-recipe-list
# https://docs.codecov.io/docs/commit-status#patch-status

coverage:
status:
Expand Down
2 changes: 2 additions & 0 deletions src/Crate/PDO/PDOImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/Crate/PDO/PDOInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions test/CrateTest/PDO/PDOStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public function testRowCount()

/**
* @covers ::fetchColumn
* @covers \Crate\PDO\Exception\InvalidArgumentException
*/
public function testFetchColumnWithInvalidColumnNumberType()
{
Expand Down Expand Up @@ -565,6 +566,7 @@ public function testFetchAll($fetchStyle, array $expected)
/**
* @covers ::fetchAll
* @covers ::doFetchAll
* @covers \Crate\PDO\Exception\InvalidArgumentException
*/
public function testFetchAllWithFetchStyleFuncAndInvalidCallback()
{
Expand Down Expand Up @@ -606,6 +608,7 @@ public function testFetchAllWithFetchStyleFunc()
/**
* @covers ::fetchAll
* @covers ::doFetchAll
* @covers \Crate\PDO\Exception\InvalidArgumentException
*/
public function testFetchAllWithFetchStyleColumnAndInvalidColumnIndexType()
{
Expand Down Expand Up @@ -741,6 +744,7 @@ public function testGetColumnMeta()
/**
* @covers ::setFetchMode
* @covers ::doSetFetchMode
* @covers \Crate\PDO\Exception\InvalidArgumentException
*/
public function testSetFetchModeWithColumnAndMissingColNo()
{
Expand All @@ -755,6 +759,7 @@ public function testSetFetchModeWithColumnAndMissingColNo()
/**
* @covers ::setFetchMode
* @covers ::doSetFetchMode
* @covers \Crate\PDO\Exception\InvalidArgumentException
*/
public function testSetFetchModeWithColumnAndInvalidColNo()
{
Expand Down Expand Up @@ -830,6 +835,8 @@ public function testSetFetchModeWithInvalidFetchStyle()
/**
* @covers ::setFetchMode
* @covers ::doSetFetchMode
* @covers \Crate\PDO\Exception\InvalidArgumentException
*
* @dataProvider fetchModeStyleProvider
*
* @param int $fetchStyle
Expand Down
1 change: 1 addition & 0 deletions test/CrateTest/PDO/PDOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public function testLastInsertIdThrowsUnsupportedException()
* Not all things have been implemented yet.
*
* @requires PHP >= 8
* @covers ::query
*
* @dataProvider fetchModeStyleProvider
* @param $fetchMode
Expand Down

0 comments on commit 4445a25

Please sign in to comment.