[wp-trac] [WordPress Trac] #56706: Tests: `parent::set_up()` calls `wp_list_pluck()`, causing inaccurate coverage.
WordPress Trac
noreply at wordpress.org
Tue Oct 4 16:19:15 UTC 2022
#56706: Tests: `parent::set_up()` calls `wp_list_pluck()`, causing inaccurate
coverage.
----------------------------------------------+-----------------------
Reporter: costdev | Owner: costdev
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.1
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-screenshots has-patch commit | Focuses:
----------------------------------------------+-----------------------
Comment (by SergeyBiryukov):
Replying to [comment:4 jrf]:
> For what's it's worth - the same problem as outlined in this ticket
applies to any and all tests involving WP native functions used in the
`set_up()` methods (and possibly the `tear_down()`, though I'd need to
check to be sure).
Thanks! At a glance, some other native WP functions used in
`WP_UnitTestCase_Base::set_up()` appear to be:
* `add_filter()`
* `add_action()`
* `wp_upload_dir()`
* `WP_Rewrite::init()`
* `WP_Rewrite::set_permalink_structure()`
* `WP_Rewrite::flush_rules()`
> So swopping out one WP native function for another is not a solution, it
just "moves" the problem to another part of the test suite.
I might be missing something, but [attachment:"56706.2.diff"] does not
replace `wp_filter_object_list()` with any other native WP function, it
just uses the globals directly. It was an attempt to implement this
suggestion from the ticket description:
> The real solution involves ensuring that the code under test is not
called in `WP_UnitTestCase_Base::set_up()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56706#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list