From 0778740cb4cc705da95f9c79d8cad87a089ee01a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Aug 2021 13:59:36 +0000 Subject: [PATCH] Tests: Move loading the `WP_Community_Events` class to `set_up_before_class()`. This ensures that the class is loaded once before the first test of the test case class is run, and `require_once()` is not unnecessarily called for each test method individually. Follow-up to [40607], [51628]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51641 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/wpCommunityEvents.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/admin/wpCommunityEvents.php b/tests/phpunit/tests/admin/wpCommunityEvents.php index 8e7b8af6a3..493ad7b68c 100644 --- a/tests/phpunit/tests/admin/wpCommunityEvents.php +++ b/tests/phpunit/tests/admin/wpCommunityEvents.php @@ -26,6 +26,17 @@ class Tests_Admin_wpCommunityEvents extends WP_UnitTestCase { */ private $instance; + /** + * Performs setup tasks before the first test is run. + * + * @since 5.9.0 + */ + public static function set_up_before_class() { + parent::set_up_before_class(); + + require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; + } + /** * Performs setup tasks for every test. * @@ -34,8 +45,6 @@ class Tests_Admin_wpCommunityEvents extends WP_UnitTestCase { public function set_up() { parent::set_up(); - require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; - $this->instance = new WP_Community_Events( 1, $this->get_user_location() ); }