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/getMediaItem.php

    r35309 r39189  
    55 */
    66class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
    7     var $post_id;
     7    protected static $post_id;
     8
    89    var $attachment_data;
    910    var $attachment_id;
     11
     12    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     13        self::$post_id = $factory->post->create();
     14    }
    1015
    1116    function setUp() {
     
    1419        add_theme_support( 'post-thumbnails' );
    1520
    16         $this->post_id = wp_insert_post( array(
    17             'post_title' => rand_str(),
    18             'post_content' => rand_str(),
    19             'post_status' => 'publish'
    20         ));
    21 
    2221        $filename = ( DIR_TESTDATA.'/images/waffles.jpg' );
    2322        $contents = file_get_contents( $filename );
    2423        $upload = wp_upload_bits(basename($filename), null, $contents);
    2524
    26         $this->attachment_id = $this->_make_attachment( $upload, $this->post_id );
     25        $this->attachment_id = $this->_make_attachment( $upload, self::$post_id );
    2726        $this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
    2827
    29         set_post_thumbnail( $this->post_id, $this->attachment_id );
     28        set_post_thumbnail( self::$post_id, $this->attachment_id );
    3029    }
    3130
Note: See TracChangeset for help on using the changeset viewer.