Tests: Restore @covers tags for PHP polyfill tests in phpunit/tests/compat/.

These tags were previously removed to avoid notices when generating the code coverage report on PHP versions where these functions are natively available and not user-defined:
{{{
"@covers ::array_key_first" is invalid
"@covers ::array_key_last" is invalid
"@covers ::hash_hmac" is invalid
"@covers ::is_countable" is invalid
"@covers ::is_iterable" is invalid
"@covers ::mb_strlen" is invalid
"@covers ::mb_substr" is invalid
"@covers ::str_contains" is invalid
"@covers ::str_ends_with" is invalid
"@covers ::str_starts_with" is invalid
}}}

It has been pointed out that those tests do cover the WP implementation of those functions and should be marked as such with a `@covers` tag. The reason PHPUnit displays notices about it, is that code coverage is only run on PHP 7.4 instead of multiple PHP versions.

For those PHP versions which don't natively contain the function, the WP polyfill is being tested and should be seen as covered by tests. The reason the tests are also run on PHP versions in which the function already exists in PHP natively, is to make sure that the polyfill test expectations line up with the PHP native behaviour, even though at that point, they are no longer testing the WP polyfill, but the PHP native function.

With the above in mind, while those PHPUnit notices add some noise to the code coverage report, in this case, they should be ignored and the `@covers` tags should be brought back.

As a potential future enhancement, the code coverage script could be updated to run against the highest and lowest supported PHP versions and with some variations of extensions enabled or disabled to ensure those tests actually test the polyfills.

Follow-up to [51852], [52038], [52039], [52040], [54049], [54060].

Props jrf.
See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54064 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-09-03 14:45:20 +00:00
parent 53a5e4f0ac
commit 18acdb68f5
10 changed files with 10 additions and 7 deletions

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::array_key_first
*/
class Tests_Compat_arrayKeyFirst extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::array_key_last
*/
class Tests_Compat_ArrayKeyLast extends WP_UnitTestCase {

View File

@ -3,6 +3,7 @@
/**
* @group compat
*
* @covers ::hash_hmac
* @covers ::_hash_hmac
*/
class Tests_Compat_hashHmac extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::is_countable
*/
class Tests_Compat_isCountable extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::is_iterable
*/
class Tests_Compat_isIterable extends WP_UnitTestCase {

View File

@ -4,6 +4,7 @@
* @group compat
* @group security-153
*
* @covers ::mb_strlen
* @covers ::_mb_strlen
*/
class Tests_Compat_mbStrlen extends WP_UnitTestCase {

View File

@ -4,6 +4,7 @@
* @group compat
* @group security-153
*
* @covers ::mb_substr
* @covers ::_mb_substr
*/
class Tests_Compat_mbSubstr extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::str_contains
*/
class Tests_Compat_strContains extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::str_ends_with
*/
class Tests_Compat_StrEndsWith extends WP_UnitTestCase {

View File

@ -3,7 +3,7 @@
/**
* @group compat
*
* @coversNothing
* @covers ::str_starts_with
*/
class Tests_Compat_StrStartsWith extends WP_UnitTestCase {