[wp-trac] [WordPress Trac] #39265: Missing @covers in the comment blocks in PHPUnit tests

WordPress Trac noreply at wordpress.org
Sat Sep 3 14:45:35 UTC 2022


#39265: Missing @covers in the comment blocks in PHPUnit tests
-------------------------------------------+-----------------------------
 Reporter:  pbearne                        |       Owner:  hellofromTonya
     Type:  task (blessed)                 |      Status:  reviewing
 Priority:  normal                         |   Milestone:  6.1
Component:  Build/Test Tools               |     Version:  4.8
 Severity:  normal                         |  Resolution:
 Keywords:  php8 has-patch has-unit-tests  |     Focuses:
-------------------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 In [changeset:"54064" 54064]:
 {{{
 #!CommitTicketReference repository="" revision="54064"
 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.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/39265#comment:113>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list