Make WordPress Core


Ignore:
Timestamp:
11/08/2014 03:29:31 PM (11 years ago)
Author:
boonebgorges
Message:

Share fixtures across a number of query-related test classes.

This shaves 10-20 seconds off the running time for the suite.

See #30017.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/date.php

    r25139 r30276  
    1111    public $q;
    1212
    13     public function setUp() {
    14         parent::setUp();
    15 
     13    static $post_ids = array();
     14
     15    public static function setUpBeforeClass() {
    1616        // Be careful modifying this. Tests are coded to expect this exact sample data.
    1717        $post_dates = array(
     
    4141        );
    4242
     43        $factory = new WP_UnitTest_Factory;
     44
    4345        foreach ( $post_dates as $post_date ) {
    44             $this->factory->post->create( array( 'post_date' => $post_date ) );
     46            self::$post_ids[] = $factory->post->create( array( 'post_date' => $post_date ) );
    4547        }
    4648
     49        self::commit_transaction();
     50    }
     51
     52    public static function tearDownAfterClass() {
     53        foreach ( self::$post_ids as $post_id ) {
     54            wp_delete_post( $post_id, true );
     55        }
     56
     57        self::commit_transaction();
     58    }
     59
     60    public function setUp() {
     61        parent::setUp();
    4762        unset( $this->q );
    4863        $this->q = new WP_Query();
Note: See TracChangeset for help on using the changeset viewer.