Make WordPress Core


Ignore:
Timestamp:
08/27/2016 08:35:16 AM (10 years ago)
Author:
wonderboymusic
Message:

Unit Tests:

  • Automatically delete objects that we were created during wpSetUpBeforeClass - posts, comments, terms (except 1), and user (except 1)
  • The amount of leftover data between tests was breathtaking - use the new function: _delete_all_data()
  • Commit database transactions for all TestCases, not just those that implement wpSetUpBeforeClass and wpTearDownAfterClass
  • The tests run 10-20 seconds faster now

See #37699.

File:
1 edited

Legend:

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

    r37861 r38398  
    6262                $c = self::get_called_class();
    6363                if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
     64                        self::commit_transaction();
    6465                        return;
    6566                }
     
    7374                parent::tearDownAfterClass();
    7475
     76                _delete_all_data();
     77                self::flush_cache();
     78
    7579                $c = self::get_called_class();
    7680                if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
     81                        self::commit_transaction();
    7782                        return;
    7883                }
     
    159164                $_GET = array();
    160165                $_POST = array();
    161                 $this->flush_cache();
     166                self::flush_cache();
    162167        }
    163168
     
    244249        }
    245250
    246         function flush_cache() {
     251        static function flush_cache() {
    247252                global $wp_object_cache;
    248253                $wp_object_cache->group_ops = array();
     
    446451                unset($_SERVER['PATH_INFO']);
    447452
    448                 $this->flush_cache();
     453                self::flush_cache();
    449454                unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
    450455                $GLOBALS['wp_the_query'] = new WP_Query();
Note: See TracChangeset for help on using the changeset viewer.