Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/query.php

    r35225 r35242  
    246246     */
    247247    public function test_orderby_clause_key_as_secondary_sort() {
    248         $u1 = self::$factory->user->create( array(
     248        $u1 = self::factory()->user->create( array(
    249249            'user_registered' => '2015-01-28 03:00:00',
    250250        ) );
    251         $u2 = self::$factory->user->create( array(
     251        $u2 = self::factory()->user->create( array(
    252252            'user_registered' => '2015-01-28 05:00:00',
    253253        ) );
    254         $u3 = self::$factory->user->create( array(
     254        $u3 = self::factory()->user->create( array(
    255255            'user_registered' => '2015-01-28 03:00:00',
    256256        ) );
     
    599599        }
    600600
    601         $b = self::$factory->blog->create();
     601        $b = self::factory()->blog->create();
    602602
    603603        add_user_to_blog( $b, self::$author_ids[0], 'author' );
     
    625625        }
    626626
    627         $b = self::$factory->blog->create();
     627        $b = self::factory()->blog->create();
    628628        add_user_to_blog( $b, self::$author_ids[0], 'author' );
    629629
     
    650650        }
    651651
    652         $b = self::$factory->blog->create();
     652        $b = self::factory()->blog->create();
    653653
    654654        add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
     
    676676        }
    677677
    678         $b = self::$factory->blog->create();
     678        $b = self::factory()->blog->create();
    679679
    680680        add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
     
    708708        register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    709709
    710         self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    711         self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
     710        self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
     711        self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    712712
    713713        $q = new WP_User_Query( array(
     
    728728        register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    729729
    730         self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    731         self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    732         self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
     730        self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
     731        self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
     732        self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    733733
    734734        $q = new WP_User_Query( array(
     
    749749        register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    750750
    751         self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) );
    752         self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) );
    753         self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
     751        self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) );
     752        self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) );
     753        self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    754754
    755755        $q = new WP_User_Query( array(
     
    771771        }
    772772
    773         $blogs = self::$factory->blog->create_many( 2 );
     773        $blogs = self::factory()->blog->create_many( 2 );
    774774
    775775        add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' );
     
    779779
    780780        switch_to_blog( $blogs[0] );
    781         self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) );
     781        self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) );
    782782        restore_current_blog();
    783783
    784784        switch_to_blog( $blogs[1] );
    785         self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) );
     785        self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) );
    786786        restore_current_blog();
    787787
     
    932932     */
    933933    public function test_get_single_role_by_string_which_is_similar() {
    934         $another_editor = self::$factory->user->create( array(
     934        $another_editor = self::factory()->user->create( array(
    935935            'role' => 'another-editor',
    936936        ) );
     
    11491149        }
    11501150
    1151         $sites = self::$factory->blog->create_many( 2 );
     1151        $sites = self::factory()->blog->create_many( 2 );
    11521152
    11531153        add_user_to_blog( $sites[0], self::$author_ids[0], 'author' );
Note: See TracChangeset for help on using the changeset viewer.