Make WordPress Core


Ignore:
Timestamp:
03/26/2019 12:45:57 AM (6 years ago)
Author:
johnbillion
Message:

Build/Test tools: Fix the Travis CI build for the 4.0 branch.

Among other fixes, this backports [29860], [29869], [29954], [30160], [30530].

Fixes #46646

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/tests/phpunit/includes/testcase.php

    r42065 r45013  
    3838        $this->factory = new WP_UnitTest_Factory;
    3939        $this->clean_up_global_scope();
     40
     41        /*
     42         * When running core tests, ensure that post types and taxonomies
     43         * are reset for each test. We skip this step for non-core tests,
     44         * given the large number of plugins that register post types and
     45         * taxonomies at 'init'.
     46         */
     47        if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
     48            $this->reset_post_types();
     49            $this->reset_taxonomies();
     50        }
     51
    4052        $this->start_transaction();
    4153        $this->expectDeprecated();
    4254        add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
     55    }
     56
     57    /**
     58     * Unregister existing post types and register defaults.
     59     *
     60     * Run before each test in order to clean up the global scope, in case
     61     * a test forgets to unregister a post type on its own, or fails before
     62     * it has a chance to do so.
     63     */
     64    protected function reset_post_types() {
     65        foreach ( get_post_types() as $pt ) {
     66            _unregister_post_type( $pt );
     67        }
     68        create_initial_post_types();
     69    }
     70
     71    /**
     72     * Unregister existing taxonomies and register defaults.
     73     *
     74     * Run before each test in order to clean up the global scope, in case
     75     * a test forgets to unregister a taxonomy on its own, or fails before
     76     * it has a chance to do so.
     77     */
     78    protected function reset_taxonomies() {
     79        foreach ( get_taxonomies() as $tax ) {
     80            _unregister_taxonomy( $tax );
     81        }
     82        create_initial_taxonomies();
    4383    }
    4484
Note: See TracChangeset for help on using the changeset viewer.