From d8598e3d0528314e1bac6bfb99d6eb8a05889503 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 14 Feb 2023 18:19:34 +0000 Subject: [PATCH] Build/Test Tools: Fix inaccurate coverage in Tests_Functions_wpListPluck::set_up(). The call stack for `WP_UnitTestCase_Base::set_up()` includes a call to `WP_List_Util::pluck()`, which creates an inaccurate coverage report for this method. To resolve, `parent::set_up()` is removed from `Tests_Functions_wpListPluck::set_up()`. To ensure that deprecation and incorrect usage notices continue to be detectable, `$this->expectDeprecated()` is added in the test's `set_up()` fixture. Follow-up to [51663], [28900]. Props costdev, jrf, SergeyBiryukov, audrasjb. Fixes #56706. git-svn-id: https://develop.svn.wordpress.org/trunk@55341 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/wpListPluck.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpListPluck.php b/tests/phpunit/tests/functions/wpListPluck.php index 63b66670c9..fa10b01595 100644 --- a/tests/phpunit/tests/functions/wpListPluck.php +++ b/tests/phpunit/tests/functions/wpListPluck.php @@ -11,7 +11,18 @@ class Tests_Functions_wpListPluck extends WP_UnitTestCase { public $array_list = array(); public function set_up() { - parent::set_up(); + /* + * This method deliberately does not call parent::set_up(). Why? + * + * The call stack for WP_UnitTestCase_Base::set_up() includes a call to + * WP_List_Util::pluck(), which creates an inaccurate coverage report + * for this method. + * + * To ensure that deprecation and incorrect usage notices continue to be + * detectable, this method uses WP_UnitTestCase_Base::expectDeprecated(). + */ + $this->expectDeprecated(); + $this->array_list['foo'] = array( 'name' => 'foo', 'id' => 'f',