From f0fa726bd51f02c2b097fb588fcee60fcfc16b6f Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Sat, 23 Dec 2023 11:23:24 +0100 Subject: [PATCH] Switch to ReflectionProperty to setStaticPropertyValue --- tests/phpunit/tests/modules/modules.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/modules/modules.php b/tests/phpunit/tests/modules/modules.php index a622cb5359450..4ca7128b63003 100644 --- a/tests/phpunit/tests/modules/modules.php +++ b/tests/phpunit/tests/modules/modules.php @@ -43,20 +43,21 @@ class Tests_Modules_Functions extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->registered = new ReflectionProperty( 'WP_Modules', 'registered' ); - $this->registered->setAccessible( true ); - $this->old_registered = $this->registered->getValue(); - $this->registered->setValue( array() ); - - $this->enqueued_before_registered = new ReflectionProperty( 'WP_Modules', 'enqueued_before_registered' ); - $this->enqueued_before_registered->setAccessible( true ); - $this->old_enqueued_before_registered = $this->enqueued_before_registered->getValue(); - $this->enqueued_before_registered->setValue( array() ); + $wp_modules = new ReflectionClass( 'WP_Modules' ); + + $this->old_registered = $wp_modules->getStaticPropertyValue( 'registered' ); + $this->old_enqueued_before_registered = $wp_modules->getStaticPropertyValue( 'enqueued_before_registered' ); + + $wp_modules->setStaticPropertyValue( 'registered', array() ); + $wp_modules->setStaticPropertyValue( 'enqueued_before_registered', array() ); } public function tear_down() { - $this->registered->setValue( $this->old_registered ); - $this->enqueued_before_registered->setValue( $this->old_enqueued_before_registered ); + $wp_modules = new ReflectionClass( 'WP_Modules' ); + + $wp_modules->setStaticPropertyValue( 'registered', $this->old_registered ); + $wp_modules->setStaticPropertyValue( 'enqueued_before_registered', $this->old_enqueued_before_registered ); + parent::tear_down(); }