File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
7878 */
7979 protected $ original_theme_features ;
8080
81+ /**
82+ * @var WP_Block_Type_Registry
83+ */
84+ protected $ original_block_type_registry ;
85+
8186 /**
8287 * @var array
8388 */
@@ -135,6 +140,8 @@ public function set_up() {
135140 foreach ( self ::RESTORED_CONFIG_OPTIONS as $ option ) {
136141 $ this ->original_ini_config [ $ option ] = ini_get ( $ option );
137142 }
143+
144+ $ this ->original_block_type_registry = WP_Block_Type_Registry::get_instance ();
138145 }
139146
140147 public function tear_down () {
@@ -150,6 +157,14 @@ public function tear_down() {
150157 unregister_post_type ( 'cpt ' );
151158 unregister_taxonomy ( 'taxo ' );
152159 $ this ->set_permalink_structure ( '' );
160+
161+ $ reflection_class = new ReflectionClass ( WP_Block_Type_Registry::class );
162+ $ instance_property = $ reflection_class ->getProperty ( 'instance ' );
163+ if ( PHP_VERSION_ID < 80100 ) {
164+ $ instance_property ->setAccessible ( true );
165+ }
166+ $ instance_property ->setValue ( null , $ this ->original_block_type_registry );
167+
153168 parent ::tear_down ();
154169 }
155170
You can’t perform that action at this time.
0 commit comments