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

    r38078 r39189  
    55 */
    66class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase {
    7     var $parent_term;
    87
    9     function setUp() {
    10         parent::setUp();
     8    protected static $parent_term_id;
    119
    12         $this->parent_term = wp_insert_term( 'parent' . rand_str(), 'category' );
    13         $this->assertInternalType( 'array', $this->parent_term );
    14         $this->parent_term = $this->parent_term['term_id'];
     10    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     11        self::$parent_term_id = $factory->term->create( array(
     12            'taxonomy' => 'category',
     13        ) );
    1514    }
    1615
     
    6059        $this->make_user_by_role( 'editor' );
    6160
    62         $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => $this->parent_term, 'name' => 'test' ) ) );
     61        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    6362        $this->assertInstanceOf( 'IXR_Error', $result );
    6463        $this->assertEquals( 403, $result->code );
     
    9594        $this->make_user_by_role( 'editor' );
    9695
    97         $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => $this->parent_term, 'name' => 'test' ) ) );
     96        $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    9897        $this->assertNotInstanceOf( 'IXR_Error', $result );
    9998        $this->assertStringMatchesFormat( '%d', $result );
     
    103102        $this->make_user_by_role( 'editor' );
    104103
    105         $taxonomy = array( 'taxonomy' => 'category', 'parent' => $this->parent_term, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
     104        $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
    106105        $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) );
    107106        $this->assertNotInstanceOf( 'IXR_Error', $result );
Note: See TracChangeset for help on using the changeset viewer.