Make WordPress Core

Changeset 31046


Ignore:
Timestamp:
01/04/2015 08:05:53 PM (12 years ago)
Author:
boonebgorges
Message:

Remove non-built-in post statuses during each unit test teardown.

See #29167.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r30687 r31046  
    4848                        $this->reset_post_types();
    4949                        $this->reset_taxonomies();
     50                        $this->reset_post_statuses();
    5051                }
    5152
     
    106107                }
    107108                create_initial_taxonomies();
     109        }
     110
     111        /**
     112         * Unregister non-built-in post statuses.
     113         */
     114        protected function reset_post_statuses() {
     115                foreach ( get_post_stati( array( '_builtin' => false ) ) as $post_status ) {
     116                        _unregister_post_status( $post_status );
     117                }
    108118        }
    109119
  • trunk/tests/phpunit/includes/utils.php

    r30528 r31046  
    332332}
    333333
     334/**
     335 * Unregister a post status.
     336 *
     337 * @since 4.2.0
     338 *
     339 * @param string $status
     340 */
     341function _unregister_post_status( $status ) {
     342        unset( $GLOBALS['wp_post_statuses'][ $status ] );
     343}
     344
    334345function _cleanup_query_vars() {
    335346        // clean out globals to stop them polluting wp and wp_query
  • trunk/tests/phpunit/tests/includes/helpers.php

    r30687 r31046  
    160160                }
    161161        }
     162
     163        public function test__unregister_post_status() {
     164                register_post_status( 'foo' );
     165                _unregister_post_status( 'foo' );
     166
     167                $stati = get_post_stati();
     168
     169                $this->assertFalse( isset( $stati['foo'] ) );
     170        }
    162171}
Note: See TracChangeset for help on using the changeset viewer.