Make WordPress Core


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

    r38698 r39189  
    55 */
    66class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase {
    7     var $term;
     7    protected static $term_id;
    88
    9     function setUp() {
    10         parent::setUp();
    11 
    12         $this->term = wp_insert_term( 'term' . rand_str() , 'category' );
    13         $this->assertInternalType( 'array', $this->term );
     9    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     10        self::$term_id = $factory->term->create( array(
     11            'taxonomy' => 'category',
     12        ) );
    1413    }
    1514
     
    4140        $this->make_user_by_role( 'subscriber' );
    4241
    43         $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
     42        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
    4443        $this->assertInstanceOf( 'IXR_Error', $result );
    4544        $this->assertEquals( 401, $result->code );
     
    6867        $this->make_user_by_role( 'editor' );
    6968
    70         $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', $this->term['term_id'] ) );
     69        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
    7170        $this->assertNotInstanceOf( 'IXR_Error', $result );
    7271        $this->assertInternalType( 'boolean', $result );
Note: See TracChangeset for help on using the changeset viewer.