Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/27/2015 01:07:53 PM (6 years ago)
Author:
netweb
Message:

Tests: Updated bbPress PHPUnit test suite compatibility with upstream WordPress changes.

  • [WP35244] WP_UnitTest_Generator_Sequence needs a static incrementer - otherwise, it assumes every test class is a reset, which it no longer is (it is now static), updated bbPress unit tests where explicitly set content and titles are required.

Props thebrandonallen. Fixes #2883

File:
1 edited

Legend:

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

    r5770 r5947  
    3434            $this->bp_factory = new BP_UnitTest_Factory();
    3535        }
     36
     37        // Our default is ugly permalinks, so reset when needed.
     38        global $wp_rewrite;
     39        if ( $wp_rewrite->permalink_structure ) {
     40            $this->set_permalink_structure();
     41        }
    3642    }
    3743
     
    325331        if ( ! empty( self::$cached_SERVER_NAME ) ) {
    326332            $_SERVER['SERVER_NAME'] = self::$cached_SERVER_NAME;
    327             unset( $this->cached_SERVER_NAME );
     333            self::$cached_SERVER_NAME = '';
    328334        } else {
    329335            unset( $_SERVER['SERVER_NAME'] );
     
    341347        $wpdb->query( 'COMMIT;' );
    342348    }
     349
     350    /**
     351     * Utility method that resets permalinks and flushes rewrites.
     352     *
     353     * @since 2.6.0 bbPress (r5947)
     354     *
     355     * @global WP_Rewrite $wp_rewrite
     356     *
     357     * @uses WP_UnitTestCase::set_permalink_structure()
     358     *
     359     * @param string $structure Optional. Permalink structure to set. Default empty.
     360     */
     361    public function set_permalink_structure( $structure = '' ) {
     362
     363        // Use WP 4.4+'s version if it exists.
     364        if ( method_exists( 'parent', 'set_permalink_structure' ) ) {
     365            parent::set_permalink_structure( $structure );
     366        } else {
     367            global $wp_rewrite;
     368
     369            $wp_rewrite->init();
     370            $wp_rewrite->set_permalink_structure( $structure );
     371            $wp_rewrite->flush_rules();
     372        }
     373    }
    343374}
Note: See TracChangeset for help on using the changeset viewer.