Make WordPress Core


Ignore:
Timestamp:
11/10/2016 01:53:08 AM (9 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/getTerm.php

    r38698 r39189  
    55 */
    66class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase {
    7     var $term;
    87
    9     function setUp() {
    10         parent::setUp();
     8    protected static $term_id;
    119
    12         $this->term = wp_insert_term( 'term' . rand_str() , 'category' );
    13         $this->assertInternalType( 'array', $this->term );
     10    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     11        self::$term_id = $factory->term->create( array(
     12            'taxonomy' => 'category',
     13        ) );
    1414    }
    1515
     
    4141        $this->make_user_by_role( 'subscriber' );
    4242
    43         $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
     43        $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
    4444        $this->assertInstanceOf( 'IXR_Error', $result );
    4545        $this->assertEquals( 401, $result->code );
     
    6969        $this->make_user_by_role( 'editor' );
    7070
    71         $term = get_term( $this->term['term_id'], 'category', ARRAY_A );
     71        $term = get_term( self::$term_id, 'category', ARRAY_A );
    7272
    73         $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', $this->term['term_id'] ) );
     73        $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
    7474
    7575        $this->assertNotInstanceOf( 'IXR_Error', $result );
Note: See TracChangeset for help on using the changeset viewer.