WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/10/2016 01:53:08 AM (4 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Re-use a bunch of fixtures in test classes for user and XMLRPC tests.

Shaves a couple of seconds off of the tests.

See #30017, #38716

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php

    r25002 r39189  
    55 */
    66class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase {
    7     var $post_data;
    8     var $post_id;
    9     var $post_date_ts;
     7    protected static $post_id;
    108
    11     function setUp() {
    12         parent::setUp();
    13 
    14         $this->post_date_ts = strtotime( '+1 day' );
    15         $this->post_data = array(
    16             'post_type' => 'page',
    17             'post_title' => rand_str(),
    18             'post_content' => rand_str( 2000 ),
    19             'post_excerpt' => rand_str( 100 ),
    20             'post_author' => $this->make_user_by_role( 'author' ),
    21             'post_date'  => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
    22         );
    23         $this->post_id = wp_insert_post( $this->post_data );
     9    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     10        self::$post_id = $factory->post->create( array(
     11            'post_type'   => 'page',
     12            'post_author' => $factory->user->create( array(
     13                'user_login' => 'author',
     14                'user_pass'  => 'author',
     15                'role'       => 'author'
     16            ) ),
     17            'post_date'   => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
     18        ) );
    2419    }
    2520
Note: See TracChangeset for help on using the changeset viewer.