WordPress.org

Make WordPress Core

Ticket #29827: 29827.patch

File 29827.patch, 1.2 KB (added by boonebgorges, 6 years ago)
  • tests/phpunit/includes/testcase.php

    diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
    index 1e8ea11..7abceae 100644
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    3737                ini_set('display_errors', 1 );
    3838                $this->factory = new WP_UnitTest_Factory;
    3939                $this->clean_up_global_scope();
     40                $this->reset_taxonomies();
    4041                $this->start_transaction();
    4142                $this->expectDeprecated();
    4243                add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    6768        }
    6869
    6970        /**
     71         * Unregister existing taxonomies and register defaults.
     72         *
     73         * Run before each test in order to clean up the global scope, in case
     74         * a test forgets to unregister a taxonomy on its own, or fails before
     75         * it has a chance to do so.
     76         */
     77        protected function reset_taxonomies() {
     78                foreach ( get_taxonomies() as $tax ) {
     79                        _unregister_taxonomy( $tax );
     80                }
     81                create_initial_taxonomies();
     82        }
     83
     84        /**
    7085         * Saves the action and filter-related globals so they can be restored later.
    7186         *
    7287         * Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter