Make WordPress Core

Ticket #56706: 56706.2.diff

File 56706.2.diff, 1.5 KB (added by SergeyBiryukov, 2 years ago)
  • tests/phpunit/includes/abstract-testcase.php

     
    280280         * it has a chance to do so.
    281281         */
    282282        protected function reset_post_types() {
    283                 foreach ( get_post_types( array(), 'objects' ) as $pt ) {
     283                global $wp_post_types;
     284
     285                foreach ( $wp_post_types as $pt ) {
    284286                        if ( empty( $pt->tests_no_auto_unregister ) ) {
    285287                                _unregister_post_type( $pt->name );
    286288                        }
    287289                }
     290
    288291                create_initial_post_types();
    289292        }
    290293
     
    296299         * it has a chance to do so.
    297300         */
    298301        protected function reset_taxonomies() {
    299                 foreach ( get_taxonomies() as $tax ) {
    300                         _unregister_taxonomy( $tax );
     302                global $wp_taxonomies;
     303
     304                foreach ( $wp_taxonomies as $tax ) {
     305                        _unregister_taxonomy( $tax->name );
    301306                }
     307
    302308                create_initial_taxonomies();
    303309        }
    304310
     
    306312         * Unregisters non-built-in post statuses.
    307313         */
    308314        protected function reset_post_statuses() {
    309                 foreach ( get_post_stati( array( '_builtin' => false ) ) as $post_status ) {
     315                global $wp_post_statuses;
     316
     317                $non_built_in_post_statuses = array();
     318
     319                foreach ( $wp_post_statuses as $post_status ) {
     320                        if ( false === $post_status->_builtin ) {
     321                                $non_built_in_post_statuses[ $post_status->name ] = $post_status->name;
     322                        }
     323                }
     324
     325                foreach ( $non_built_in_post_statuses as $post_status ) {
    310326                        _unregister_post_status( $post_status );
    311327                }
    312328        }