Make WordPress Core

Changeset 54090


Ignore:
Timestamp:
09/06/2022 10:09:49 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use the factory method instead of the property.

This replaces all references to the WP_UnitTestCase_Base::$factory property with static function calls to the WP_UnitTestCase_Base::factory() method.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087], [54088].

Props jrf.
See #55652.

Location:
trunk/tests/phpunit/tests
Files:
52 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesScreen.php

    r52010 r54090  
    496496
    497497        if ( 'post.php' === $hook ) {
    498             $post_id      = $this->factory->post->create(
     498            $post_id      = self::factory()->post->create(
    499499                array(
    500500                    'post_type' => 'type_shows_in_rest',
  • trunk/tests/phpunit/tests/admin/includesTheme.php

    r53916 r54090  
    231231     */
    232232    public function test_get_theme_featured_list_api() {
    233         wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
     233        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    234234        $featured_list_api = get_theme_feature_list( true );
    235235        $this->assertNonEmptyMultidimensionalArray( $featured_list_api );
  • trunk/tests/phpunit/tests/auth.php

    r54088 r54090  
    408408            'user_pass'  => 'password',
    409409        );
    410         $this->factory->user->create( $user_args );
     410        self::factory()->user->create( $user_args );
    411411
    412412        $this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_email'], $user_args['user_pass'] ) );
  • trunk/tests/phpunit/tests/category/walkerCategory.php

    r53684 r54090  
    3131    public function test_start_el_with_empty_attributes( $value, $expected ) {
    3232        $output   = '';
    33         $category = $this->factory->category->create_and_get();
     33        $category = self::factory()->category->create_and_get();
    3434        $link     = get_term_link( $category );
    3535
  • trunk/tests/phpunit/tests/comment.php

    r53863 r54090  
    721721         * Set up a comment for testing.
    722722         */
    723         $post = $this->factory->post->create(
     723        $post = self::factory()->post->create(
    724724            array(
    725725                'post_author' => self::$user_id,
     
    727727        );
    728728
    729         $comment = $this->factory->comment->create(
     729        $comment = self::factory()->comment->create(
    730730            array(
    731731                'comment_post_ID' => $post,
  • trunk/tests/phpunit/tests/comment/checkComment.php

    r54088 r54090  
    147147
    148148        // Make sure comment author has an approved comment.
    149         $this->factory->comment->create(
     149        self::factory()->comment->create(
    150150            array(
    151151                'user_id'              => $subscriber_id,
  • trunk/tests/phpunit/tests/comment/commentsOpen.php

    r52223 r54090  
    1818     */
    1919    public function test_post_exist_status_open() {
    20         $post = $this->factory->post->create_and_get();
     20        $post = self::factory()->post->create_and_get();
    2121        $this->assertTrue( comments_open( $post ) );
    2222    }
     
    2626     */
    2727    public function test_post_exist_status_closed() {
    28         $post                 = $this->factory->post->create_and_get();
     28        $post                 = self::factory()->post->create_and_get();
    2929        $post->comment_status = 'closed';
    3030
  • trunk/tests/phpunit/tests/comment/pingsOpen.php

    r52223 r54090  
    1818     */
    1919    public function test_post_exist_status_open() {
    20         $post = $this->factory->post->create_and_get();
     20        $post = self::factory()->post->create_and_get();
    2121        $this->assertTrue( pings_open( $post ) );
    2222    }
     
    2626     */
    2727    public function test_post_exist_status_closed() {
    28         $post              = $this->factory->post->create_and_get();
     28        $post              = self::factory()->post->create_and_get();
    2929        $post->ping_status = 'closed';
    3030
  • trunk/tests/phpunit/tests/comment/template.php

    r53863 r54090  
    5959    public function test_get_comments_number_text_with_post_id() {
    6060        $post_id = self::$post_id;
    61         $this->factory->comment->create_post_comments( $post_id, 6 );
     61        self::factory()->comment->create_post_comments( $post_id, 6 );
    6262
    6363        $comments_number_text = get_comments_number_text( false, false, false, $post_id );
     
    8585        $this->assertSame( __( 'No Comments' ), get_comments_number_text() );
    8686
    87         $this->factory->comment->create_post_comments( $post_id, 1 );
     87        self::factory()->comment->create_post_comments( $post_id, 1 );
    8888        $this->go_to( $permalink );
    8989
    9090        $this->assertSame( __( '1 Comment' ), get_comments_number_text() );
    9191
    92         $this->factory->comment->create_post_comments( $post_id, 1 );
     92        self::factory()->comment->create_post_comments( $post_id, 1 );
    9393        $this->go_to( $permalink );
    9494
     
    107107        $permalink = get_permalink( $post_id );
    108108
    109         $this->factory->comment->create_post_comments( $post_id, $number );
     109        self::factory()->comment->create_post_comments( $post_id, $number );
    110110        $this->go_to( $permalink );
    111111
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r54088 r54090  
    418418        );
    419419
    420         $term_id = $this->factory->term->create(
     420        $term_id = self::factory()->term->create(
    421421            array(
    422422                'taxonomy' => 'wptests_tax',
  • trunk/tests/phpunit/tests/date/getFeedBuildDate.php

    r52010 r54090  
    5656        $this->assertFalse( get_feed_build_date( DATE_RFC3339 ), 'False when unable to determine valid time' );
    5757
    58         $this->factory->post->create(
     58        self::factory()->post->create(
    5959            array(
    6060                'post_date' => $datetime->format( 'Y-m-d H:i:s' ),
     
    6969        );
    7070
    71         $post_id_broken = $this->factory->post->create();
     71        $post_id_broken = self::factory()->post->create();
    7272        $post_broken    = get_post( $post_id_broken );
    7373
  • trunk/tests/phpunit/tests/date/getTheModifiedDate.php

    r50291 r54090  
    2121            'post_date_gmt' => '2016-01-21 15:34:36',
    2222        );
    23         $post_id  = $this->factory->post->create( $details );
     23        $post_id  = self::factory()->post->create( $details );
    2424        $format   = 'Y-m-d';
    2525        $expected = '2016-01-21';
     
    4040            'post_date_gmt' => '2016-01-21 15:34:36',
    4141        );
    42         $post_id = $this->factory->post->create( $details );
     42        $post_id = self::factory()->post->create( $details );
    4343        $post    = get_post( $post_id );
    4444
     
    112112            'post_date_gmt' => '2016-01-21 15:34:36',
    113113        );
    114         $post_id  = $this->factory->post->create( $details );
     114        $post_id  = self::factory()->post->create( $details );
    115115        $format   = 'G';
    116116        $expected = 1453390476;
     
    131131            'post_date_gmt' => '2016-01-21 15:34:36',
    132132        );
    133         $post_id = $this->factory->post->create( $details );
     133        $post_id = self::factory()->post->create( $details );
    134134        $post    = get_post( $post_id );
    135135
  • trunk/tests/phpunit/tests/date/xmlrpc.php

    r52389 r54090  
    222222
    223223        $this->make_user_by_role( 'administrator' );
    224         $post_id = $this->factory->post->create();
     224        $post_id = self::factory()->post->create();
    225225
    226226        $comment_data = array(
  • trunk/tests/phpunit/tests/general/template.php

    r54088 r54090  
    105105     */
    106106    public function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() {
    107         $blog_id = $this->factory->blog->create();
     107        $blog_id = self::factory()->blog->create();
    108108        switch_to_blog( $blog_id );
    109109        $this->set_site_icon();
     
    120120     */
    121121    public function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() {
    122         $blog_id = $this->factory->blog->create();
     122        $blog_id = self::factory()->blog->create();
    123123
    124124        $this->assertFalse( has_site_icon( $blog_id ) );
     
    299299     */
    300300    public function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() {
    301         $blog_id = $this->factory->blog->create();
     301        $blog_id = self::factory()->blog->create();
    302302        switch_to_blog( $blog_id );
    303303        $this->set_custom_logo();
     
    314314     */
    315315    public function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() {
    316         $blog_id = $this->factory->blog->create();
     316        $blog_id = self::factory()->blog->create();
    317317
    318318        $this->assertFalse( has_custom_logo( $blog_id ) );
     
    344344     */
    345345    public function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() {
    346         $blog_id = $this->factory->blog->create();
     346        $blog_id = self::factory()->blog->create();
    347347        switch_to_blog( $blog_id );
    348348
     
    467467     */
    468468    public function test_get_site_icon_url_preserves_switched_state() {
    469         $blog_id = $this->factory->blog->create();
     469        $blog_id = self::factory()->blog->create();
    470470        switch_to_blog( $blog_id );
    471471
     
    487487     */
    488488    public function test_has_custom_logo_preserves_switched_state() {
    489         $blog_id = $this->factory->blog->create();
     489        $blog_id = self::factory()->blog->create();
    490490        switch_to_blog( $blog_id );
    491491
     
    507507     */
    508508    public function test_get_custom_logo_preserves_switched_state() {
    509         $blog_id = $this->factory->blog->create();
     509        $blog_id = self::factory()->blog->create();
    510510        switch_to_blog( $blog_id );
    511511
  • trunk/tests/phpunit/tests/general/wpGetDocumentTitle.php

    r53815 r54090  
    102102        update_option(
    103103            'page_on_front',
    104             $this->factory->post->create(
     104            self::factory()->post->create(
    105105                array(
    106106                    'post_title' => 'front-page',
     
    129129
    130130    public function test_home_title() {
    131         $blog_page_id = $this->factory->post->create(
     131        $blog_page_id = self::factory()->post->create(
    132132            array(
    133133                'post_title' => 'blog-page',
     
    206206        );
    207207
    208         $this->factory->post->create(
     208        self::factory()->post->create(
    209209            array(
    210210                'post_type' => 'cpt',
  • trunk/tests/phpunit/tests/image/functions.php

    r54086 r54090  
    659659        }
    660660
    661         $attachment_id = $this->factory->attachment->create_object(
     661        $attachment_id = self::factory()->attachment->create_object(
    662662            $test_file,
    663663            0,
     
    736736        }
    737737
    738         $attachment_id = $this->factory->attachment->create_object(
     738        $attachment_id = self::factory()->attachment->create_object(
    739739            $test_file,
    740740            0,
     
    809809        }
    810810
    811         $attachment_id = $this->factory->attachment->create_object(
     811        $attachment_id = self::factory()->attachment->create_object(
    812812            $test_file,
    813813            0,
     
    883883        }
    884884
    885         $attachment_id = $this->factory->attachment->create_object(
     885        $attachment_id = self::factory()->attachment->create_object(
    886886            $pdf_path,
    887887            0,
  • trunk/tests/phpunit/tests/link/getPostTypeArchiveLink.php

    r50454 r54090  
    2020     */
    2121    public function test_get_post_archive_link_with_post_archive_on_a_blog_page() {
    22         $page_for_posts = $this->factory->post->create(
     22        $page_for_posts = self::factory()->post->create(
    2323            array(
    2424                'post_title' => 'blog-page',
  • trunk/tests/phpunit/tests/link/getThePrivacyPolicyLink.php

    r51462 r54090  
    116116     */
    117117    public function test_function_should_return_empty_string_when_privacy_page_title_empty() {
    118         $nameless_page_id = $this->factory->post->create(
     118        $nameless_page_id = self::factory()->post->create(
    119119            array(
    120120                'post_type'  => 'page',
  • trunk/tests/phpunit/tests/media/getPostGalleries.php

    r53852 r54090  
    2929     */
    3030    public function test_returns_empty_array_with_post_with_no_gallery() {
    31         $post_id = $this->factory->post->create(
     31        $post_id = self::factory()->post->create(
    3232            array(
    3333                'post_content' => '<p>A post with no gallery</p>',
     
    5050     */
    5151    public function test_returns_only_galleries( $content, $needle ) {
    52         $image_id = $this->factory->attachment->create_object(
     52        $image_id = self::factory()->attachment->create_object(
    5353            array(
    5454                'file'           => 'test.jpg',
     
    6767        );
    6868
    69         $post_id = $this->factory->post->create(
     69        $post_id = self::factory()->post->create(
    7070            array(
    7171                'post_content' => $content,
     
    125125    public function test_returns_no_srcs_with_shortcode_in_post_with_no_attached_images() {
    126126        // Set up an unattached image.
    127         $this->factory->attachment->create_object(
     127        self::factory()->attachment->create_object(
    128128            array(
    129129                'file'           => 'test.jpg',
     
    134134        );
    135135
    136         $post_id = $this->factory->post->create(
     136        $post_id = self::factory()->post->create(
    137137            array(
    138138                'post_content' => '[gallery]',
     
    174174    public function test_returns_no_srcs_with_block_in_post_with_no_attached_images() {
    175175        // Set up an unattached image.
    176         $this->factory->attachment->create_object(
     176        self::factory()->attachment->create_object(
    177177            array(
    178178                'file'           => 'test.jpg',
     
    183183        );
    184184
    185         $post_id = $this->factory->post->create(
     185        $post_id = self::factory()->post->create(
    186186            array(
    187187                'post_content' => '<!-- wp:gallery -->',
     
    232232    public function test_returns_no_srcs_with_block_v2_in_post_with_no_attached_images() {
    233233        // Set up an unattached image.
    234         $image_id = $this->factory->attachment->create_object(
     234        $image_id = self::factory()->attachment->create_object(
    235235            array(
    236236                'file'           => 'test.jpg',
     
    261261BLOB;
    262262
    263         $post_id = $this->factory->post->create(
     263        $post_id = self::factory()->post->create(
    264264            array(
    265265                'post_content' => $blob,
     
    310310     */
    311311    public function test_returns_html_with_shortcode_gallery() {
    312         $post_id = $this->factory->post->create(
     312        $post_id = self::factory()->post->create(
    313313            array(
    314314                'post_content' => 'I have no gallery',
     
    316316        );
    317317
    318         $post_id_two = $this->factory->post->create(
     318        $post_id_two = self::factory()->post->create(
    319319            array(
    320320                'post_content' => "[gallery id='$post_id']",
     
    322322        );
    323323
    324         $this->factory->attachment->create_object(
     324        self::factory()->attachment->create_object(
    325325            array(
    326326                'file'           => 'test.jpg',
     
    364364     */
    365365    public function test_returns_html_with_block_gallery() {
    366         $post_id = $this->factory->post->create(
     366        $post_id = self::factory()->post->create(
    367367            array(
    368368                'post_content' => 'I have no gallery.',
     
    371371
    372372        // Set up an unattached image.
    373         $image_id = $this->factory->attachment->create(
     373        $image_id = self::factory()->attachment->create(
    374374            array(
    375375                'file'           => 'test.jpg',
     
    388388BLOB;
    389389
    390         $post_id_two = $this->factory->post->create(
     390        $post_id_two = self::factory()->post->create(
    391391            array(
    392392                'post_content' => $blob,
     
    427427     */
    428428    public function test_returns_html_with_block_gallery_v2() {
    429         $image_id = $this->factory->attachment->create_object(
     429        $image_id = self::factory()->attachment->create_object(
    430430            array(
    431431                'file'           => 'test.jpg',
     
    456456BLOB;
    457457
    458         $post_id = $this->factory->post->create(
     458        $post_id = self::factory()->post->create(
    459459            array(
    460460                'post_content' => $blob,
     
    496496     */
    497497    public function test_respects_post_id_with_shortcode_gallery() {
    498         $global_post_id = $this->factory->post->create(
     498        $global_post_id = self::factory()->post->create(
    499499            array(
    500500                'post_content' => 'Global Post',
    501501            )
    502502        );
    503         $post_id        = $this->factory->post->create(
     503        $post_id        = self::factory()->post->create(
    504504            array(
    505505                'post_content' => '[gallery]',
    506506            )
    507507        );
    508         $this->factory->attachment->create_object(
     508        self::factory()->attachment->create_object(
    509509            array(
    510510                'file'           => 'test.jpg',
     
    578578        $ids_joined = join( ',', $ids );
    579579
    580         $global_post_id = $this->factory->post->create(
     580        $global_post_id = self::factory()->post->create(
    581581            array(
    582582                'post_content' => 'Global Post',
     
    589589BLOB;
    590590
    591         $post_id = $this->factory->post->create(
     591        $post_id = self::factory()->post->create(
    592592            array(
    593593                'post_content' => $blob,
    594594            )
    595595        );
    596         $this->factory->attachment->create_object(
     596        self::factory()->attachment->create_object(
    597597            array(
    598598                'file'           => 'test.jpg',
     
    658658        $metadata       = array_merge( array( 'file' => 'image1.jpg' ), self::IMG_META );
    659659        $url            = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . 'image1.jpg';
    660         $global_post_id = $this->factory->post->create(
     660        $global_post_id = self::factory()->post->create(
    661661            array(
    662662                'post_content' => 'Global Post',
     
    684684BLOB;
    685685
    686         $post_id = $this->factory->post->create(
     686        $post_id = self::factory()->post->create(
    687687            array(
    688688                'post_content' => $blob,
    689689            )
    690690        );
    691         $this->factory->attachment->create_object(
     691        self::factory()->attachment->create_object(
    692692            array(
    693693                'file'           => 'test.jpg',
     
    743743     */
    744744    public function test_respects_shortcode_id_attribute() {
    745         $post_id     = $this->factory->post->create(
     745        $post_id     = self::factory()->post->create(
    746746            array(
    747747                'post_content' => 'No gallery defined',
    748748            )
    749749        );
    750         $post_id_two = $this->factory->post->create(
     750        $post_id_two = self::factory()->post->create(
    751751            array(
    752752                'post_content' => "[gallery id='$post_id']",
    753753            )
    754754        );
    755         $this->factory->attachment->create_object(
     755        self::factory()->attachment->create_object(
    756756            array(
    757757                'file'           => 'test.jpg',
     
    951951    public function test_returns_srcs_from_html_with_block_with_no_json_blob() {
    952952        // Set up an unattached image.
    953         $image_id = $this->factory->attachment->create_object(
     953        $image_id = self::factory()->attachment->create_object(
    954954            array(
    955955                'file'           => 'test.jpg',
     
    973973BLOB;
    974974
    975         $post_id = $this->factory->post->create(
     975        $post_id = self::factory()->post->create(
    976976            array(
    977977                'post_content' => $blob,
     
    10231023     */
    10241024    public function test_returns_srcs_with_nested_block_gallery() {
    1025         $post_id  = $this->factory->post->create(
     1025        $post_id  = self::factory()->post->create(
    10261026            array(
    10271027                'post_content' => 'I have no gallery.',
    10281028            )
    10291029        );
    1030         $image_id = $this->factory->attachment->create_object(
     1030        $image_id = self::factory()->attachment->create_object(
    10311031            array(
    10321032                'file'           => 'test.jpg',
     
    10461046BLOB;
    10471047
    1048         $post_id_two = $this->factory->post->create( array( 'post_content' => $blob ) );
     1048        $post_id_two = self::factory()->post->create( array( 'post_content' => $blob ) );
    10491049
    10501050        $galleries = get_post_galleries( $post_id_two, false );
  • trunk/tests/phpunit/tests/menu/walker-nav-menu-edit.php

    r53948 r54090  
    4141        $expected = '';
    4242
    43         $post_id = $this->factory->post->create();
     43        $post_id = self::factory()->post->create();
    4444
    4545        $item = array(
  • trunk/tests/phpunit/tests/menu/walker-nav-menu.php

    r53948 r54090  
    5050    public function test_noopener_no_referrer_for_target_blank() {
    5151        $actual     = '';
    52         $post_id    = $this->factory->post->create();
     52        $post_id    = self::factory()->post->create();
    5353        $post_title = get_the_title( $post_id );
    5454
     
    8181    public function test_start_el_with_empty_attributes( $value, $expected ) {
    8282        $output     = '';
    83         $post_id    = $this->factory->post->create();
     83        $post_id    = self::factory()->post->create();
    8484        $post_title = get_the_title( $post_id );
    8585
  • trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

    r51419 r54090  
    105105        register_taxonomy( 'wptests_tax', 'post' );
    106106
    107         $this->factory->term->create(
     107        self::factory()->term->create(
    108108            array(
    109109                'taxonomy' => 'wptests_tax',
  • trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php

    r51860 r54090  
    1414         */
    1515        public function test_option_should_not_be_empty_by_default() {
    16             $blog_id = $this->factory->blog->create();
     16            $blog_id = self::factory()->blog->create();
    1717
    1818            switch_to_blog( $blog_id );
     
    4040            update_site_option( 'first_comment', '' );
    4141
    42             $blog_id = $this->factory->blog->create();
     42            $blog_id = self::factory()->blog->create();
    4343
    4444            switch_to_blog( $blog_id );
     
    6666            update_site_option( 'first_comment', 'Some comment content' );
    6767
    68             $blog_id = $this->factory->blog->create();
     68            $blog_id = self::factory()->blog->create();
    6969
    7070            switch_to_blog( $blog_id );
  • trunk/tests/phpunit/tests/post.php

    r54088 r54090  
    455455        add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
    456456
    457         $post_id = $this->factory->post->create(
     457        $post_id = self::factory()->post->create(
    458458            array(
    459459                'title'       => 'An example',
  • trunk/tests/phpunit/tests/post/walkerPage.php

    r51657 r54090  
    2929    public function test_start_el_with_empty_attributes( $value, $expected ) {
    3030        $output = '';
    31         $page   = $this->factory->post->create_and_get( array( 'post_type' => 'page' ) );
     31        $page   = self::factory()->post->create_and_get( array( 'post_type' => 'page' ) );
    3232        $link   = get_permalink( $page );
    3333
  • trunk/tests/phpunit/tests/post/wpPublishPost.php

    r53783 r54090  
    143143    public function test_wp_publish_post_respects_current_categories() {
    144144        $post_id     = self::$auto_draft_id;
    145         $category_id = $this->factory->term->create( array( 'taxonomy' => 'category' ) );
     145        $category_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
    146146        wp_set_post_categories( $post_id, $category_id );
    147147        wp_publish_post( $post_id );
     
    184184    public function test_wp_publish_post_adds_default_category_when_tagged() {
    185185        $post_id = self::$auto_draft_id;
    186         $tag_id  = $this->factory->term->create( array( 'taxonomy' => 'post_tag' ) );
     186        $tag_id  = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) );
    187187        wp_set_post_tags( $post_id, array( $tag_id ) );
    188188        wp_publish_post( $post_id );
     
    219219
    220220        $post_id = self::$auto_draft_id;
    221         $term_id = $this->factory->term->create( array( 'taxonomy' => 'tax_51292' ) );
     221        $term_id = self::factory()->term->create( array( 'taxonomy' => 'tax_51292' ) );
    222222        wp_set_object_terms( $post_id, array( $term_id ), 'tax_51292' );
    223223        wp_publish_post( $post_id );
  • trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php

    r51568 r54090  
    132132     */
    133133    public function test_should_send_email_with_privacy_policy() {
    134         $privacy_policy = $this->factory->post->create(
     134        $privacy_policy = self::factory()->post->create(
    135135            array(
    136136                'post_type'   => 'page',
     
    308308     */
    309309    public function test_should_not_send_email_when_not_user_request() {
    310         $post_id = $this->factory->post->create(
     310        $post_id = self::factory()->post->create(
    311311            array(
    312312                'post_type' => 'post', // Should be 'user_request'.
  • trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php

    r51568 r54090  
    5656     */
    5757    public function test_function_should_not_send_email_when_not_a_wp_user_request() {
    58         $post_id = $this->factory->post->create(
     58        $post_id = self::factory()->post->create(
    5959            array(
    6060                'post_type' => 'post',
  • trunk/tests/phpunit/tests/query.php

    r53861 r54090  
    645645        register_taxonomy( 'tax2', 'post' );
    646646
    647         $term1   = $this->factory->term->create(
     647        $term1   = self::factory()->term->create(
    648648            array(
    649649                'taxonomy' => 'tax1',
     
    651651            )
    652652        );
    653         $term2   = $this->factory->term->create(
     653        $term2   = self::factory()->term->create(
    654654            array(
    655655                'taxonomy' => 'tax2',
     
    657657            )
    658658        );
    659         $post_id = $this->factory->post->create();
     659        $post_id = self::factory()->post->create();
    660660        wp_set_object_terms( $post_id, 'term1', 'tax1' );
    661661        wp_set_object_terms( $post_id, 'term2', 'tax2' );
     
    675675        register_taxonomy( 'tax2', 'post' );
    676676
    677         $term1   = $this->factory->term->create(
     677        $term1   = self::factory()->term->create(
    678678            array(
    679679                'taxonomy' => 'tax1',
     
    681681            )
    682682        );
    683         $term2   = $this->factory->term->create(
     683        $term2   = self::factory()->term->create(
    684684            array(
    685685                'taxonomy' => 'tax2',
     
    687687            )
    688688        );
    689         $post_id = $this->factory->post->create();
     689        $post_id = self::factory()->post->create();
    690690        wp_set_object_terms( $post_id, 'term1', 'tax1' );
    691691        wp_set_object_terms( $post_id, 'term2', 'tax2' );
  • trunk/tests/phpunit/tests/query/conditionals.php

    r53429 r54090  
    979979        $this->set_permalink_structure( '/%postname%/' );
    980980
    981         $attachment_id = $this->factory->post->create(
     981        $attachment_id = self::factory()->post->create(
    982982            array(
    983983                'post_type' => 'attachment',
     
    985985        );
    986986
    987         $post_id = $this->factory->post->create(
     987        $post_id = self::factory()->post->create(
    988988            array(
    989989                'post_title' => get_post( $attachment_id )->post_title,
  • trunk/tests/phpunit/tests/query/noFoundRows.php

    r51462 r54090  
    7474     */
    7575    public function test_no_found_rows_default_with_nopaging_true() {
    76         $p = $this->factory->post->create();
     76        $p = self::factory()->post->create();
    7777
    7878        $q = new WP_Query(
     
    9191     */
    9292    public function test_no_found_rows_default_with_postsperpage_minus1() {
    93         $p = $this->factory->post->create();
     93        $p = self::factory()->post->create();
    9494
    9595        $q = new WP_Query(
  • trunk/tests/phpunit/tests/query/search.php

    r52389 r54090  
    267267     */
    268268    public function test_s_zero() {
    269         $p1 = $this->factory->post->create(
     269        $p1 = self::factory()->post->create(
    270270            array(
    271271                'post_status'  => 'publish',
     
    276276        );
    277277
    278         $p2 = $this->factory->post->create(
     278        $p2 = self::factory()->post->create(
    279279            array(
    280280                'post_status'  => 'publish',
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r54086 r54090  
    186186        $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    187187        // Single.
    188         $attachment_id = $this->factory->attachment->create_object(
     188        $attachment_id = self::factory()->attachment->create_object(
    189189            $this->test_file,
    190190            0,
     
    247247
    248248    public function test_registered_get_item_params() {
    249         $id1      = $this->factory->attachment->create_object(
     249        $id1      = self::factory()->attachment->create_object(
    250250            $this->test_file,
    251251            0,
     
    267267     */
    268268    public function test_allow_header_sent_on_options_request() {
    269         $id1      = $this->factory->attachment->create_object(
     269        $id1      = self::factory()->attachment->create_object(
    270270            $this->test_file,
    271271            0,
     
    295295    public function test_get_items() {
    296296        wp_set_current_user( 0 );
    297         $id1            = $this->factory->attachment->create_object(
    298             $this->test_file,
    299             0,
    300             array(
    301                 'post_mime_type' => 'image/jpeg',
    302                 'post_excerpt'   => 'A sample caption',
    303             )
    304         );
    305         $draft_post     = $this->factory->post->create( array( 'post_status' => 'draft' ) );
    306         $id2            = $this->factory->attachment->create_object(
     297        $id1            = self::factory()->attachment->create_object(
     298            $this->test_file,
     299            0,
     300            array(
     301                'post_mime_type' => 'image/jpeg',
     302                'post_excerpt'   => 'A sample caption',
     303            )
     304        );
     305        $draft_post     = self::factory()->post->create( array( 'post_status' => 'draft' ) );
     306        $id2            = self::factory()->attachment->create_object(
    307307            $this->test_file,
    308308            $draft_post,
     
    312312            )
    313313        );
    314         $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    315         $id3            = $this->factory->attachment->create_object(
     314        $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     315        $id3            = self::factory()->attachment->create_object(
    316316            $this->test_file,
    317317            $published_post,
     
    335335    public function test_get_items_logged_in_editor() {
    336336        wp_set_current_user( self::$editor_id );
    337         $id1            = $this->factory->attachment->create_object(
    338             $this->test_file,
    339             0,
    340             array(
    341                 'post_mime_type' => 'image/jpeg',
    342                 'post_excerpt'   => 'A sample caption',
    343             )
    344         );
    345         $draft_post     = $this->factory->post->create( array( 'post_status' => 'draft' ) );
    346         $id2            = $this->factory->attachment->create_object(
     337        $id1            = self::factory()->attachment->create_object(
     338            $this->test_file,
     339            0,
     340            array(
     341                'post_mime_type' => 'image/jpeg',
     342                'post_excerpt'   => 'A sample caption',
     343            )
     344        );
     345        $draft_post     = self::factory()->post->create( array( 'post_status' => 'draft' ) );
     346        $id2            = self::factory()->attachment->create_object(
    347347            $this->test_file,
    348348            $draft_post,
     
    352352            )
    353353        );
    354         $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    355         $id3            = $this->factory->attachment->create_object(
     354        $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     355        $id3            = self::factory()->attachment->create_object(
    356356            $this->test_file,
    357357            $published_post,
     
    373373
    374374    public function test_get_items_media_type() {
    375         $id1      = $this->factory->attachment->create_object(
     375        $id1      = self::factory()->attachment->create_object(
    376376            $this->test_file,
    377377            0,
     
    396396
    397397    public function test_get_items_mime_type() {
    398         $id1      = $this->factory->attachment->create_object(
     398        $id1      = self::factory()->attachment->create_object(
    399399            $this->test_file,
    400400            0,
     
    419419
    420420    public function test_get_items_parent() {
    421         $post_id        = $this->factory->post->create( array( 'post_title' => 'Test Post' ) );
    422         $attachment_id  = $this->factory->attachment->create_object(
     421        $post_id        = self::factory()->post->create( array( 'post_title' => 'Test Post' ) );
     422        $attachment_id  = self::factory()->attachment->create_object(
    423423            $this->test_file,
    424424            $post_id,
     
    428428            )
    429429        );
    430         $attachment_id2 = $this->factory->attachment->create_object(
     430        $attachment_id2 = self::factory()->attachment->create_object(
    431431            $this->test_file,
    432432            0,
     
    464464    public function test_get_items_invalid_status_param_is_error_response() {
    465465        wp_set_current_user( self::$editor_id );
    466         $this->factory->attachment->create_object(
     466        self::factory()->attachment->create_object(
    467467            $this->test_file,
    468468            0,
     
    482482        // Logged out users can't make the request.
    483483        wp_set_current_user( 0 );
    484         $attachment_id1 = $this->factory->attachment->create_object(
     484        $attachment_id1 = self::factory()->attachment->create_object(
    485485            $this->test_file,
    486486            0,
     
    506506        // Logged out users can't make the request.
    507507        wp_set_current_user( 0 );
    508         $attachment_id1 = $this->factory->attachment->create_object(
     508        $attachment_id1 = self::factory()->attachment->create_object(
    509509            $this->test_file,
    510510            0,
     
    515515            )
    516516        );
    517         $attachment_id2 = $this->factory->attachment->create_object(
     517        $attachment_id2 = self::factory()->attachment->create_object(
    518518            $this->test_file,
    519519            0,
     
    551551
    552552    public function test_get_items_valid_date() {
    553         $id1     = $this->factory->attachment->create_object(
     553        $id1     = self::factory()->attachment->create_object(
    554554            $this->test_file,
    555555            0,
     
    560560            )
    561561        );
    562         $id2     = $this->factory->attachment->create_object(
     562        $id2     = self::factory()->attachment->create_object(
    563563            $this->test_file,
    564564            0,
     
    569569            )
    570570        );
    571         $id3     = $this->factory->attachment->create_object(
     571        $id3     = self::factory()->attachment->create_object(
    572572            $this->test_file,
    573573            0,
     
    602602     */
    603603    public function test_get_items_valid_modified_date() {
    604         $id1 = $this->factory->attachment->create_object(
     604        $id1 = self::factory()->attachment->create_object(
    605605            $this->test_file,
    606606            0,
     
    611611            )
    612612        );
    613         $id2 = $this->factory->attachment->create_object(
     613        $id2 = self::factory()->attachment->create_object(
    614614            $this->test_file,
    615615            0,
     
    620620            )
    621621        );
    622         $id3 = $this->factory->attachment->create_object(
     622        $id3 = self::factory()->attachment->create_object(
    623623            $this->test_file,
    624624            0,
     
    662662     */
    663663    public function test_get_items_with_empty_page_runs_count_query_after() {
    664         $this->factory->attachment->create_object(
     664        self::factory()->attachment->create_object(
    665665            $this->test_file,
    666666            0,
     
    684684
    685685    public function test_get_item() {
    686         $attachment_id = $this->factory->attachment->create_object(
     686        $attachment_id = self::factory()->attachment->create_object(
    687687            $this->test_file,
    688688            0,
     
    704704     */
    705705    public function test_get_item_sizes() {
    706         $attachment_id = $this->factory->attachment->create_object(
     706        $attachment_id = self::factory()->attachment->create_object(
    707707            $this->test_file,
    708708            0,
     
    735735     */
    736736    public function test_get_item_sizes_with_no_url() {
    737         $attachment_id = $this->factory->attachment->create_object(
     737        $attachment_id = self::factory()->attachment->create_object(
    738738            $this->test_file,
    739739            0,
     
    762762    public function test_get_item_private_post_not_authenticated() {
    763763        wp_set_current_user( 0 );
    764         $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
    765         $id1        = $this->factory->attachment->create_object(
     764        $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) );
     765        $id1        = self::factory()->attachment->create_object(
    766766            $this->test_file,
    767767            $draft_post,
     
    777777
    778778    public function test_get_item_inherit_status_with_invalid_parent() {
    779         $attachment_id = $this->factory->attachment->create_object(
     779        $attachment_id = self::factory()->attachment->create_object(
    780780            $this->test_file,
    781781            REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     
    794794
    795795    public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() {
    796         $attachment_id = $this->factory->attachment->create_object(
     796        $attachment_id = self::factory()->attachment->create_object(
    797797            $this->test_file,
    798798            REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     
    964964
    965965    public function test_create_item_invalid_edit_permissions() {
    966         $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
     966        $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
    967967        wp_set_current_user( self::$author_id );
    968968        $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
     
    973973
    974974    public function test_create_item_invalid_upload_permissions() {
    975         $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
     975        $post_id = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
    976976        wp_set_current_user( self::$uploader_id );
    977977        $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
     
    982982
    983983    public function test_create_item_invalid_post_type() {
    984         $attachment_id = $this->factory->post->create(
     984        $attachment_id = self::factory()->post->create(
    985985            array(
    986986                'post_type'   => 'attachment',
     
    10471047    public function test_update_item() {
    10481048        wp_set_current_user( self::$editor_id );
    1049         $attachment_id = $this->factory->attachment->create_object(
     1049        $attachment_id = self::factory()->attachment->create_object(
    10501050            $this->test_file,
    10511051            0,
     
    10761076    public function test_update_item_parent() {
    10771077        wp_set_current_user( self::$editor_id );
    1078         $original_parent = $this->factory->post->create( array() );
    1079         $attachment_id   = $this->factory->attachment->create_object(
     1078        $original_parent = self::factory()->post->create( array() );
     1079        $attachment_id   = self::factory()->attachment->create_object(
    10801080            $this->test_file,
    10811081            $original_parent,
     
    10901090        $this->assertSame( $original_parent, $attachment->post_parent );
    10911091
    1092         $new_parent = $this->factory->post->create( array() );
     1092        $new_parent = self::factory()->post->create( array() );
    10931093        $request    = new WP_REST_Request( 'POST', '/wp/v2/media/' . $attachment_id );
    10941094        $request->set_param( 'post', $new_parent );
     
    11011101    public function test_update_item_invalid_permissions() {
    11021102        wp_set_current_user( self::$author_id );
    1103         $attachment_id = $this->factory->attachment->create_object(
     1103        $attachment_id = self::factory()->attachment->create_object(
    11041104            $this->test_file,
    11051105            0,
     
    11171117
    11181118    public function test_update_item_invalid_post_type() {
    1119         $attachment_id = $this->factory->post->create(
     1119        $attachment_id = self::factory()->post->create(
    11201120            array(
    11211121                'post_type'   => 'attachment',
     
    11251125        );
    11261126        wp_set_current_user( self::$editor_id );
    1127         $attachment_id = $this->factory->attachment->create_object(
     1127        $attachment_id = self::factory()->attachment->create_object(
    11281128            $this->test_file,
    11291129            0,
     
    14491449    public function test_delete_item() {
    14501450        wp_set_current_user( self::$editor_id );
    1451         $attachment_id    = $this->factory->attachment->create_object(
     1451        $attachment_id    = self::factory()->attachment->create_object(
    14521452            $this->test_file,
    14531453            0,
     
    14651465    public function test_delete_item_no_trash() {
    14661466        wp_set_current_user( self::$editor_id );
    1467         $attachment_id = $this->factory->attachment->create_object(
     1467        $attachment_id = self::factory()->attachment->create_object(
    14681468            $this->test_file,
    14691469            0,
     
    14901490    public function test_delete_item_invalid_delete_permissions() {
    14911491        wp_set_current_user( self::$author_id );
    1492         $attachment_id = $this->factory->attachment->create_object(
     1492        $attachment_id = self::factory()->attachment->create_object(
    14931493            $this->test_file,
    14941494            0,
     
    15051505
    15061506    public function test_prepare_item() {
    1507         $attachment_id = $this->factory->attachment->create_object(
     1507        $attachment_id = self::factory()->attachment->create_object(
    15081508            $this->test_file,
    15091509            0,
     
    15241524
    15251525    public function test_prepare_item_limit_fields() {
    1526         $attachment_id = $this->factory->attachment->create_object(
     1526        $attachment_id = self::factory()->attachment->create_object(
    15271527            $this->test_file,
    15281528            0,
     
    16151615        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    16161616
    1617         $attachment_id = $this->factory->attachment->create_object(
     1617        $attachment_id = self::factory()->attachment->create_object(
    16181618            $this->test_file,
    16191619            0,
     
    16521652
    16531653        wp_set_current_user( self::$editor_id );
    1654         $attachment_id = $this->factory->attachment->create_object(
     1654        $attachment_id = self::factory()->attachment->create_object(
    16551655            $this->test_file,
    16561656            0,
     
    16781678
    16791679    public function test_search_item_by_filename() {
    1680         $id1 = $this->factory->attachment->create_object(
    1681             $this->test_file,
    1682             0,
    1683             array(
    1684                 'post_mime_type' => 'image/jpeg',
    1685             )
    1686         );
    1687         $id2 = $this->factory->attachment->create_object(
     1680        $id1 = self::factory()->attachment->create_object(
     1681            $this->test_file,
     1682            0,
     1683            array(
     1684                'post_mime_type' => 'image/jpeg',
     1685            )
     1686        );
     1687        $id2 = self::factory()->attachment->create_object(
    16881688            $this->test_file2,
    16891689            0,
     
    19361936
    19371937        wp_set_current_user( self::$editor_id );
    1938         $attachment_id = $this->factory->attachment->create_object(
     1938        $attachment_id = self::factory()->attachment->create_object(
    19391939            $this->test_file,
    19401940            0,
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r53909 r54090  
    122122        $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    123123        // Single.
    124         $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );
     124        $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) );
    125125        $request   = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 );
    126126        $response  = rest_get_server()->dispatch( $request );
     
    173173
    174174    public function test_get_items_hide_empty_arg() {
    175         $post_id   = $this->factory->post->create();
    176         $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );
    177         $category2 = $this->factory->category->create( array( 'name' => 'The Be Sharps' ) );
     175        $post_id   = self::factory()->post->create();
     176        $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) );
     177        $category2 = self::factory()->category->create( array( 'name' => 'The Be Sharps' ) );
    178178
    179179        $total_categories = self::$total_categories + 2;
     
    198198
    199199    public function test_get_items_parent_zero_arg() {
    200         $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );
    201         $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );
    202         $this->factory->category->create(
     200        $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) );
     201        $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) );
     202        self::factory()->category->create(
    203203            array(
    204204                'name'   => 'Bart',
     
    206206            )
    207207        );
    208         $this->factory->category->create(
     208        self::factory()->category->create(
    209209            array(
    210210                'name'   => 'Lisa',
     
    230230
    231231    public function test_get_items_parent_zero_arg_string() {
    232         $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );
    233         $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );
    234         $this->factory->category->create(
     232        $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) );
     233        $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) );
     234        self::factory()->category->create(
    235235            array(
    236236                'name'   => 'Bart',
     
    238238            )
    239239        );
    240         $this->factory->category->create(
     240        self::factory()->category->create(
    241241            array(
    242242                'name'   => 'Lisa',
     
    262262
    263263    public function test_get_items_by_parent_non_found() {
    264         $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );
     264        $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) );
    265265
    266266        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    285285
    286286    public function test_get_items_include_query() {
    287         $id1 = $this->factory->category->create();
    288         $id2 = $this->factory->category->create();
     287        $id1 = self::factory()->category->create();
     288        $id2 = self::factory()->category->create();
    289289
    290290        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    306306
    307307    public function test_get_items_exclude_query() {
    308         $id1 = $this->factory->category->create();
    309         $id2 = $this->factory->category->create();
     308        $id1 = self::factory()->category->create();
     309        $id2 = self::factory()->category->create();
    310310
    311311        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    326326
    327327    public function test_get_items_orderby_args() {
    328         $this->factory->category->create( array( 'name' => 'Apple' ) );
    329         $this->factory->category->create( array( 'name' => 'Banana' ) );
     328        self::factory()->category->create( array( 'name' => 'Apple' ) );
     329        self::factory()->category->create( array( 'name' => 'Banana' ) );
    330330
    331331        /*
     
    357357
    358358    public function test_get_items_orderby_id() {
    359         $this->factory->category->create( array( 'name' => 'Cantaloupe' ) );
    360         $this->factory->category->create( array( 'name' => 'Apple' ) );
    361         $this->factory->category->create( array( 'name' => 'Banana' ) );
     359        self::factory()->category->create( array( 'name' => 'Cantaloupe' ) );
     360        self::factory()->category->create( array( 'name' => 'Apple' ) );
     361        self::factory()->category->create( array( 'name' => 'Banana' ) );
    362362
    363363        // Defaults to 'orderby' => 'name', 'order' => 'asc'.
     
    393393
    394394    public function test_get_items_orderby_slugs() {
    395         $this->factory->category->create( array( 'name' => 'Burrito' ) );
    396         $this->factory->category->create( array( 'name' => 'Taco' ) );
    397         $this->factory->category->create( array( 'name' => 'Chalupa' ) );
     395        self::factory()->category->create( array( 'name' => 'Burrito' ) );
     396        self::factory()->category->create( array( 'name' => 'Taco' ) );
     397        self::factory()->category->create( array( 'name' => 'Chalupa' ) );
    398398
    399399        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    409409
    410410    protected function post_with_categories() {
    411         $post_id   = $this->factory->post->create();
    412         $category1 = $this->factory->category->create(
     411        $post_id   = self::factory()->post->create();
     412        $category1 = self::factory()->category->create(
    413413            array(
    414414                'name'        => 'DC',
     
    416416            )
    417417        );
    418         $category2 = $this->factory->category->create(
     418        $category2 = self::factory()->category->create(
    419419            array(
    420420                'name'        => 'Marvel',
     
    422422            )
    423423        );
    424         $category3 = $this->factory->category->create(
     424        $category3 = self::factory()->category->create(
    425425            array(
    426426                'name'        => 'Image',
     
    494494        $controller = new WP_REST_Terms_Controller( 'batman' );
    495495        $controller->register_routes();
    496         $term1 = $this->factory->term->create(
     496        $term1 = self::factory()->term->create(
    497497            array(
    498498                'name'     => 'Cape',
     
    500500            )
    501501        );
    502         $term2 = $this->factory->term->create(
     502        $term2 = self::factory()->term->create(
    503503            array(
    504504                'name'     => 'Mask',
     
    506506            )
    507507        );
    508         $this->factory->term->create(
     508        self::factory()->term->create(
    509509            array(
    510510                'name'     => 'Car',
     
    512512            )
    513513        );
    514         $post_id = $this->factory->post->create();
     514        $post_id = self::factory()->post->create();
    515515        wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' );
    516516
     
    526526
    527527    public function test_get_items_search_args() {
    528         $this->factory->category->create( array( 'name' => 'Apple' ) );
    529         $this->factory->category->create( array( 'name' => 'Banana' ) );
     528        self::factory()->category->create( array( 'name' => 'Apple' ) );
     529        self::factory()->category->create( array( 'name' => 'Banana' ) );
    530530
    531531        /*
     
    550550
    551551    public function test_get_items_slug_arg() {
    552         $this->factory->category->create( array( 'name' => 'Apple' ) );
    553         $this->factory->category->create( array( 'name' => 'Banana' ) );
     552        self::factory()->category->create( array( 'name' => 'Apple' ) );
     553        self::factory()->category->create( array( 'name' => 'Banana' ) );
    554554
    555555        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    563563
    564564    public function test_get_terms_parent_arg() {
    565         $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) );
    566         $this->factory->category->create(
     565        $category1 = self::factory()->category->create( array( 'name' => 'Parent' ) );
     566        self::factory()->category->create(
    567567            array(
    568568                'name'   => 'Child',
     
    588588    public function test_get_terms_private_taxonomy() {
    589589        register_taxonomy( 'robin', 'post', array( 'public' => false ) );
    590         $this->factory->term->create(
     590        self::factory()->term->create(
    591591            array(
    592592                'name'     => 'Cape',
     
    594594            )
    595595        );
    596         $this->factory->term->create(
     596        self::factory()->term->create(
    597597            array(
    598598                'name'     => 'Mask',
     
    633633
    634634        // 3rd page.
    635         $this->factory->category->create();
     635        self::factory()->category->create();
    636636        $total_categories++;
    637637        $total_pages++;
     
    776776    public function test_get_term_private_taxonomy() {
    777777        register_taxonomy( 'robin', 'post', array( 'public' => false ) );
    778         $term1 = $this->factory->term->create(
     778        $term1 = self::factory()->term->create(
    779779            array(
    780780                'name'     => 'Cape',
     
    790790    public function test_get_item_incorrect_taxonomy() {
    791791        register_taxonomy( 'robin', 'post' );
    792         $term1 = $this->factory->term->create(
     792        $term1 = self::factory()->term->create(
    793793            array(
    794794                'name'     => 'Cape',
     
    825825        wp_set_current_user( self::$administrator );
    826826
    827         $existing_id = $this->factory->category->create( array( 'name' => 'Existing' ) );
     827        $existing_id = self::factory()->category->create( array( 'name' => 'Existing' ) );
    828828
    829829        $request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
     
    891891        wp_set_current_user( self::$administrator );
    892892
    893         $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
     893        $term = get_term_by( 'id', self::factory()->category->create(), 'category' );
    894894
    895895        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
     
    923923        );
    924924
    925         $term = get_term_by( 'id', $this->factory->category->create( $orig_args ), 'category' );
     925        $term = get_term_by( 'id', self::factory()->category->create( $orig_args ), 'category' );
    926926
    927927        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
     
    969969        wp_set_current_user( self::$subscriber );
    970970
    971         $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
     971        $term = get_term_by( 'id', self::factory()->category->create(), 'category' );
    972972
    973973        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
     
    980980        wp_set_current_user( self::$administrator );
    981981
    982         $parent = get_term_by( 'id', $this->factory->category->create(), 'category' );
    983         $term   = get_term_by( 'id', $this->factory->category->create(), 'category' );
     982        $parent = get_term_by( 'id', self::factory()->category->create(), 'category' );
     983        $term   = get_term_by( 'id', self::factory()->category->create(), 'category' );
    984984
    985985        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
     
    995995        wp_set_current_user( self::$administrator );
    996996
    997         $old_parent_term = get_term_by( 'id', $this->factory->category->create(), 'category' );
     997        $old_parent_term = get_term_by( 'id', self::factory()->category->create(), 'category' );
    998998        $new_parent_id   = 0;
    999999
    10001000        $term = get_term_by(
    10011001            'id',
    1002             $this->factory->category->create(
     1002            self::factory()->category->create(
    10031003                array(
    10041004                    'parent' => $old_parent_term->term_id,
     
    10221022        wp_set_current_user( self::$administrator );
    10231023
    1024         $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
     1024        $term = get_term_by( 'id', self::factory()->category->create(), 'category' );
    10251025
    10261026        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
     
    10331033        wp_set_current_user( self::$administrator );
    10341034
    1035         $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
     1035        $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
    10361036
    10371037        $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
     
    10471047        wp_set_current_user( self::$administrator );
    10481048
    1049         $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
     1049        $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
    10501050
    10511051        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
     
    10771077        wp_set_current_user( self::$subscriber );
    10781078
    1079         $term     = get_term_by( 'id', $this->factory->category->create(), 'category' );
     1079        $term     = get_term_by( 'id', self::factory()->category->create(), 'category' );
    10801080        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
    10811081        $response = rest_get_server()->dispatch( $request );
     
    11091109
    11101110    public function test_prepare_taxonomy_term_child() {
    1111         $child = $this->factory->category->create(
     1111        $child = self::factory()->category->create(
    11121112            array(
    11131113                'parent' => 1,
     
    11711171        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    11721172
    1173         $category_id = $this->factory->category->create();
     1173        $category_id = self::factory()->category->create();
    11741174        $request     = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $category_id );
    11751175
  • trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r53909 r54090  
    238238        );
    239239
    240         $password_comment = $this->factory->comment->create( $args );
     240        $password_comment = self::factory()->comment->create( $args );
    241241
    242242        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    262262        );
    263263
    264         $password_comment = $this->factory->comment->create( $args );
     264        $password_comment = self::factory()->comment->create( $args );
    265265
    266266        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    285285        );
    286286
    287         $password_comment = $this->factory->comment->create( $args );
     287        $password_comment = self::factory()->comment->create( $args );
    288288
    289289        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    303303        );
    304304
    305         $password_comment = $this->factory->comment->create( $args );
     305        $password_comment = self::factory()->comment->create( $args );
    306306
    307307        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    322322        );
    323323
    324         $password_comment = $this->factory->comment->create( $args );
     324        $password_comment = self::factory()->comment->create( $args );
    325325
    326326        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    341341        );
    342342
    343         $private_comment = $this->factory->comment->create( $args );
     343        $private_comment = self::factory()->comment->create( $args );
    344344
    345345        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    360360        );
    361361
    362         $private_comment = $this->factory->comment->create( $args );
     362        $private_comment = self::factory()->comment->create( $args );
    363363
    364364        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    374374        wp_set_current_user( 0 );
    375375
    376         $comment_id = $this->factory->comment->create(
     376        $comment_id = self::factory()->comment->create(
    377377            array(
    378378                'comment_approved' => 1,
     
    395395        wp_set_current_user( self::$admin_id );
    396396
    397         $comment_id = $this->factory->comment->create(
     397        $comment_id = self::factory()->comment->create(
    398398            array(
    399399                'comment_approved' => 1,
     
    425425        wp_set_current_user( self::$admin_id );
    426426
    427         $this->factory->comment->create_post_comments( 0, 2 );
     427        self::factory()->comment->create_post_comments( 0, 2 );
    428428
    429429        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    454454
    455455    public function test_get_items_for_post() {
    456         $second_post_id = $this->factory->post->create();
    457         $this->factory->comment->create_post_comments( $second_post_id, 2 );
     456        $second_post_id = self::factory()->post->create();
     457        self::factory()->comment->create_post_comments( $second_post_id, 2 );
    458458
    459459        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    479479        );
    480480
    481         $id1 = $this->factory->comment->create( $args );
    482         $id2 = $this->factory->comment->create( $args );
     481        $id1 = self::factory()->comment->create( $args );
     482        $id2 = self::factory()->comment->create( $args );
    483483
    484484        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    519519        );
    520520
    521         $id1 = $this->factory->comment->create( $args );
    522         $id2 = $this->factory->comment->create( $args );
     521        $id1 = self::factory()->comment->create( $args );
     522        $id2 = self::factory()->comment->create( $args );
    523523
    524524        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    575575        );
    576576
    577         $id = $this->factory->comment->create( $args );
     577        $id = self::factory()->comment->create( $args );
    578578
    579579        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    599599        wp_set_current_user( 0 );
    600600
    601         $post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );
     601        $post_id = self::factory()->post->create( array( 'post_status' => 'private' ) );
    602602
    603603        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    617617        );
    618618
    619         $this->factory->comment->create( $args );
     619        self::factory()->comment->create( $args );
    620620        $args['user_id'] = self::$subscriber_id;
    621         $this->factory->comment->create( $args );
     621        self::factory()->comment->create( $args );
    622622        unset( $args['user_id'] );
    623         $this->factory->comment->create( $args );
     623        self::factory()->comment->create( $args );
    624624
    625625        // Limit to comment author.
     
    660660        );
    661661
    662         $this->factory->comment->create( $args );
     662        self::factory()->comment->create( $args );
    663663        $args['user_id'] = self::$subscriber_id;
    664         $this->factory->comment->create( $args );
     664        self::factory()->comment->create( $args );
    665665        unset( $args['user_id'] );
    666         $this->factory->comment->create( $args );
     666        self::factory()->comment->create( $args );
    667667
    668668        $total_comments = self::$total_comments + 3;
     
    710710            'comment_post_ID'  => self::$post_id,
    711711        );
    712         $parent_id              = $this->factory->comment->create( $args );
    713         $parent_id2             = $this->factory->comment->create( $args );
     712        $parent_id              = self::factory()->comment->create( $args );
     713        $parent_id2             = self::factory()->comment->create( $args );
    714714        $args['comment_parent'] = $parent_id;
    715         $this->factory->comment->create( $args );
     715        self::factory()->comment->create( $args );
    716716        $args['comment_parent'] = $parent_id2;
    717         $this->factory->comment->create( $args );
     717        self::factory()->comment->create( $args );
    718718
    719719        $total_comments = self::$total_comments + 4;
     
    746746            'comment_post_ID'  => self::$post_id,
    747747        );
    748         $parent_id              = $this->factory->comment->create( $args );
    749         $parent_id2             = $this->factory->comment->create( $args );
     748        $parent_id              = self::factory()->comment->create( $args );
     749        $parent_id2             = self::factory()->comment->create( $args );
    750750        $args['comment_parent'] = $parent_id;
    751         $this->factory->comment->create( $args );
     751        self::factory()->comment->create( $args );
    752752        $args['comment_parent'] = $parent_id2;
    753         $this->factory->comment->create( $args );
     753        self::factory()->comment->create( $args );
    754754
    755755        $total_comments = self::$total_comments + 4;
     
    787787        );
    788788
    789         $id = $this->factory->comment->create( $args );
     789        $id = self::factory()->comment->create( $args );
    790790
    791791        $total_comments = self::$total_comments + 1;
     
    826826
    827827        // 3rd page.
    828         $this->factory->comment->create(
     828        self::factory()->comment->create(
    829829            array(
    830830                'comment_post_ID' => self::$post_id,
     
    896896
    897897    public function test_get_comments_valid_date() {
    898         $comment1 = $this->factory->comment->create(
     898        $comment1 = self::factory()->comment->create(
    899899            array(
    900900                'comment_date'    => '2016-01-15T00:00:00Z',
     
    902902            )
    903903        );
    904         $comment2 = $this->factory->comment->create(
     904        $comment2 = self::factory()->comment->create(
    905905            array(
    906906                'comment_date'    => '2016-01-16T00:00:00Z',
     
    908908            )
    909909        );
    910         $comment3 = $this->factory->comment->create(
     910        $comment3 = self::factory()->comment->create(
    911911            array(
    912912                'comment_date'    => '2016-01-17T00:00:00Z',
     
    10041004        wp_set_current_user( 0 );
    10051005
    1006         $comment_id = $this->factory->comment->create(
     1006        $comment_id = self::factory()->comment->create(
    10071007            array(
    10081008                'comment_approved' => 1,
     
    10191019        wp_set_current_user( self::$admin_id );
    10201020
    1021         $comment_id = $this->factory->comment->create(
     1021        $comment_id = self::factory()->comment->create(
    10221022            array(
    10231023                'comment_approved' => 1,
     
    10481048
    10491049    public function test_get_comment_with_children_link() {
    1050         $comment_id_1 = $this->factory->comment->create(
     1050        $comment_id_1 = self::factory()->comment->create(
    10511051            array(
    10521052                'comment_approved' => 1,
     
    10561056        );
    10571057
    1058         $child_comment = $this->factory->comment->create(
     1058        $child_comment = self::factory()->comment->create(
    10591059            array(
    10601060                'comment_approved' => 1,
     
    10721072
    10731073    public function test_get_comment_without_children_link() {
    1074         $comment_id_1 = $this->factory->comment->create(
     1074        $comment_id_1 = self::factory()->comment->create(
    10751075            array(
    10761076                'comment_approved' => 1,
     
    10941094        );
    10951095
    1096         $password_comment = $this->factory->comment->create( $args );
     1096        $password_comment = self::factory()->comment->create( $args );
    10971097
    10981098        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) );
     
    11121112        );
    11131113
    1114         $password_comment = $this->factory->comment->create( $args );
     1114        $password_comment = self::factory()->comment->create( $args );
    11151115
    11161116        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) );
     
    14911491
    14921492    public function test_create_item_assign_different_user() {
    1493         $subscriber_id = $this->factory->user->create(
     1493        $subscriber_id = self::factory()->user->create(
    14941494            array(
    14951495                'role'       => 'subscriber',
     
    15221522
    15231523    public function test_create_comment_without_type() {
    1524         $post_id = $this->factory->post->create();
     1524        $post_id = self::factory()->post->create();
    15251525
    15261526        wp_set_current_user( self::$admin_id );
     
    15601560     */
    15611561    public function test_create_comment_with_invalid_type() {
    1562         $post_id = $this->factory->post->create();
     1562        $post_id = self::factory()->post->create();
    15631563
    15641564        wp_set_current_user( self::$admin_id );
     
    15841584
    15851585    public function test_create_comment_invalid_email() {
    1586         $post_id = $this->factory->post->create();
     1586        $post_id = self::factory()->post->create();
    15871587
    15881588        wp_set_current_user( self::$admin_id );
     
    16071607
    16081608    public function test_create_item_current_user() {
    1609         $user_id = $this->factory->user->create(
     1609        $user_id = self::factory()->user->create(
    16101610            array(
    16111611                'role'         => 'subscriber',
     
    17291729
    17301730    public function test_create_comment_with_status_IP_and_user_agent() {
    1731         $post_id = $this->factory->post->create();
     1731        $post_id = self::factory()->post->create();
    17321732
    17331733        wp_set_current_user( self::$admin_id );
     
    20072007        wp_set_current_user( self::$subscriber_id );
    20082008
    2009         $this->factory->comment->create(
     2009        self::factory()->comment->create(
    20102010            array(
    20112011                'comment_post_ID'      => self::$post_id,
     
    20322032
    20332033    public function test_create_comment_closed() {
    2034         $post_id = $this->factory->post->create(
     2034        $post_id = self::factory()->post->create(
    20352035            array(
    20362036                'comment_status' => 'closed',
     
    23042304
    23052305    public function test_update_item() {
    2306         $post_id = $this->factory->post->create();
     2306        $post_id = self::factory()->post->create();
    23072307
    23082308        wp_set_current_user( self::$admin_id );
     
    23482348        update_option( 'timezone_string', $params['timezone_string'] );
    23492349
    2350         $comment_id = $this->factory->comment->create();
     2350        $comment_id = self::factory()->comment->create();
    23512351
    23522352        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) );
     
    23752375
    23762376    public function test_update_item_no_content() {
    2377         $post_id = $this->factory->post->create();
     2377        $post_id = self::factory()->post->create();
    23782378
    23792379        wp_set_current_user( self::$admin_id );
     
    24132413        wp_set_current_user( self::$admin_id );
    24142414
    2415         $comment_id = $this->factory->comment->create(
     2415        $comment_id = self::factory()->comment->create(
    24162416            array(
    24172417                'comment_approved' => 0,
     
    24402440        wp_set_current_user( self::$admin_id );
    24412441
    2442         $comment_id = $this->factory->comment->create(
     2442        $comment_id = self::factory()->comment->create(
    24432443            array(
    24442444                'comment_approved' => 0,
     
    27212721
    27222722    public function test_update_comment_private_post_invalid_permission() {
    2723         $private_comment_id = $this->factory->comment->create(
     2723        $private_comment_id = self::factory()->comment->create(
    27242724            array(
    27252725                'comment_approved' => 1,
     
    27462746        wp_set_current_user( self::$admin_id );
    27472747
    2748         $comment_id_1 = $this->factory->comment->create(
     2748        $comment_id_1 = self::factory()->comment->create(
    27492749            array(
    27502750                'comment_approved' => 1,
     
    27542754        );
    27552755
    2756         $child_comment = $this->factory->comment->create(
     2756        $child_comment = self::factory()->comment->create(
    27572757            array(
    27582758                'comment_approved' => 1,
     
    30483048        wp_set_current_user( self::$admin_id );
    30493049
    3050         $comment_id = $this->factory->comment->create(
     3050        $comment_id = self::factory()->comment->create(
    30513051            array(
    30523052                'comment_approved' => 1,
     
    30683068        wp_set_current_user( self::$admin_id );
    30693069
    3070         $comment_id = $this->factory->comment->create(
     3070        $comment_id = self::factory()->comment->create(
    30713071            array(
    30723072                'comment_approved' => 1,
     
    30893089        wp_set_current_user( self::$admin_id );
    30903090
    3091         $comment_id = $this->factory->comment->create(
     3091        $comment_id = self::factory()->comment->create(
    30923092            array(
    30933093                'comment_approved' => 1,
     
    31243124        wp_set_current_user( self::$admin_id );
    31253125
    3126         $comment_id_1 = $this->factory->comment->create(
     3126        $comment_id_1 = self::factory()->comment->create(
    31273127            array(
    31283128                'comment_approved' => 1,
     
    31323132        );
    31333133
    3134         $child_comment = $this->factory->comment->create(
     3134        $child_comment = self::factory()->comment->create(
    31353135            array(
    31363136                'comment_approved' => 1,
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r54058 r54090  
    5252        $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    5353        // Single.
    54         $page_id  = $this->factory->post->create( array( 'post_type' => 'page' ) );
     54        $page_id  = self::factory()->post->create( array( 'post_type' => 'page' ) );
    5555        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id );
    5656        $response = rest_get_server()->dispatch( $request );
     
    9595
    9696    public function test_get_items() {
    97         $id1      = $this->factory->post->create(
    98             array(
    99                 'post_status' => 'publish',
    100                 'post_type'   => 'page',
    101             )
    102         );
    103         $id2      = $this->factory->post->create(
     97        $id1      = self::factory()->post->create(
     98            array(
     99                'post_status' => 'publish',
     100                'post_type'   => 'page',
     101            )
     102        );
     103        $id2      = self::factory()->post->create(
    104104            array(
    105105                'post_status' => 'draft',
     
    115115
    116116    public function test_get_items_parent_query() {
    117         $id1 = $this->factory->post->create(
    118             array(
    119                 'post_status' => 'publish',
    120                 'post_type'   => 'page',
    121             )
    122         );
    123         $id2 = $this->factory->post->create(
     117        $id1 = self::factory()->post->create(
     118            array(
     119                'post_status' => 'publish',
     120                'post_type'   => 'page',
     121            )
     122        );
     123        $id2 = self::factory()->post->create(
    124124            array(
    125125                'post_status' => 'publish',
     
    149149
    150150    public function test_get_items_parents_query() {
    151         $id1 = $this->factory->post->create(
    152             array(
    153                 'post_status' => 'publish',
    154                 'post_type'   => 'page',
    155             )
    156         );
    157         $id2 = $this->factory->post->create(
     151        $id1 = self::factory()->post->create(
     152            array(
     153                'post_status' => 'publish',
     154                'post_type'   => 'page',
     155            )
     156        );
     157        $id2 = self::factory()->post->create(
    158158            array(
    159159                'post_status' => 'publish',
     
    162162            )
    163163        );
    164         $id3 = $this->factory->post->create(
    165             array(
    166                 'post_status' => 'publish',
    167                 'post_type'   => 'page',
    168             )
    169         );
    170         $id4 = $this->factory->post->create(
     164        $id3 = self::factory()->post->create(
     165            array(
     166                'post_status' => 'publish',
     167                'post_type'   => 'page',
     168            )
     169        );
     170        $id4 = self::factory()->post->create(
    171171            array(
    172172                'post_status' => 'publish',
     
    191191
    192192    public function test_get_items_parent_exclude_query() {
    193         $id1 = $this->factory->post->create(
    194             array(
    195                 'post_status' => 'publish',
    196                 'post_type'   => 'page',
    197             )
    198         );
    199         $this->factory->post->create(
     193        $id1 = self::factory()->post->create(
     194            array(
     195                'post_status' => 'publish',
     196                'post_type'   => 'page',
     197            )
     198        );
     199        self::factory()->post->create(
    200200            array(
    201201                'post_status' => 'publish',
     
    225225
    226226    public function test_get_items_menu_order_query() {
    227         $id1 = $this->factory->post->create(
    228             array(
    229                 'post_status' => 'publish',
    230                 'post_type'   => 'page',
    231             )
    232         );
    233         $id2 = $this->factory->post->create(
     227        $id1 = self::factory()->post->create(
     228            array(
     229                'post_status' => 'publish',
     230                'post_type'   => 'page',
     231            )
     232        );
     233        $id2 = self::factory()->post->create(
    234234            array(
    235235                'post_status' => 'publish',
     
    238238            )
    239239        );
    240         $id3 = $this->factory->post->create(
     240        $id3 = self::factory()->post->create(
    241241            array(
    242242                'post_status' => 'publish',
     
    245245            )
    246246        );
    247         $id4 = $this->factory->post->create(
     247        $id4 = self::factory()->post->create(
    248248            array(
    249249                'post_status' => 'publish',
     
    303303        // Private query vars inaccessible to unauthorized users.
    304304        wp_set_current_user( 0 );
    305         $page_id  = $this->factory->post->create(
    306             array(
    307                 'post_status' => 'publish',
    308                 'post_type'   => 'page',
    309             )
    310         );
    311         $draft_id = $this->factory->post->create(
     305        $page_id  = self::factory()->post->create(
     306            array(
     307                'post_status' => 'publish',
     308                'post_type'   => 'page',
     309            )
     310        );
     311        $draft_id = self::factory()->post->create(
    312312            array(
    313313                'post_status' => 'draft',
     
    337337
    338338    public function test_get_items_valid_date() {
    339         $post1   = $this->factory->post->create(
     339        $post1   = self::factory()->post->create(
    340340            array(
    341341                'post_date' => '2016-01-15T00:00:00Z',
     
    343343            )
    344344        );
    345         $post2   = $this->factory->post->create(
     345        $post2   = self::factory()->post->create(
    346346            array(
    347347                'post_date' => '2016-01-16T00:00:00Z',
     
    349349            )
    350350        );
    351         $post3   = $this->factory->post->create(
     351        $post3   = self::factory()->post->create(
    352352            array(
    353353                'post_date' => '2016-01-17T00:00:00Z',
     
    379379     */
    380380    public function test_get_items_valid_modified_date() {
    381         $post1 = $this->factory->post->create(
     381        $post1 = self::factory()->post->create(
    382382            array(
    383383                'post_date' => '2016-01-01 00:00:00',
     
    385385            )
    386386        );
    387         $post2 = $this->factory->post->create(
     387        $post2 = self::factory()->post->create(
    388388            array(
    389389                'post_date' => '2016-01-02 00:00:00',
     
    391391            )
    392392        );
    393         $post3 = $this->factory->post->create(
     393        $post3 = self::factory()->post->create(
    394394            array(
    395395                'post_date' => '2016-01-03 00:00:00',
     
    417417
    418418    public function test_get_item_invalid_post_type() {
    419         $post_id  = $this->factory->post->create();
     419        $post_id  = self::factory()->post->create();
    420420        $request  = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id );
    421421        $response = rest_get_server()->dispatch( $request );
     
    449449
    450450    public function test_create_page_with_parent() {
    451         $page_id = $this->factory->post->create(
     451        $page_id = self::factory()->post->create(
    452452            array(
    453453                'type' => 'page',
     
    499499
    500500    public function test_delete_item() {
    501         $page_id = $this->factory->post->create(
     501        $page_id = self::factory()->post->create(
    502502            array(
    503503                'post_type'  => 'page',
     
    526526    public function test_prepare_item_limit_fields() {
    527527        wp_set_current_user( self::$editor_id );
    528         $page_id  = $this->factory->post->create(
     528        $page_id  = self::factory()->post->create(
    529529            array(
    530530                'post_status' => 'publish',
     
    548548
    549549    public function test_get_pages_params() {
    550         $this->factory->post->create_many(
     550        self::factory()->post->create_many(
    551551            8,
    552552            array(
     
    579579    public function test_update_page_menu_order() {
    580580
    581         $page_id = $this->factory->post->create(
     581        $page_id = self::factory()->post->create(
    582582            array(
    583583                'post_type' => 'page',
     
    602602    public function test_update_page_menu_order_to_zero() {
    603603
    604         $page_id = $this->factory->post->create(
     604        $page_id = self::factory()->post->create(
    605605            array(
    606606                'post_type'  => 'page',
     
    625625
    626626    public function test_update_page_parent_non_zero() {
    627         $page_id1 = $this->factory->post->create(
    628             array(
    629                 'post_type' => 'page',
    630             )
    631         );
    632         $page_id2 = $this->factory->post->create(
     627        $page_id1 = self::factory()->post->create(
     628            array(
     629                'post_type' => 'page',
     630            )
     631        );
     632        $page_id2 = self::factory()->post->create(
    633633            array(
    634634                'post_type' => 'page',
     
    648648
    649649    public function test_update_page_parent_zero() {
    650         $page_id1 = $this->factory->post->create(
    651             array(
    652                 'post_type' => 'page',
    653             )
    654         );
    655         $page_id2 = $this->factory->post->create(
     650        $page_id1 = self::factory()->post->create(
     651            array(
     652                'post_type' => 'page',
     653            )
     654        );
     655        $page_id2 = self::factory()->post->create(
    656656            array(
    657657                'post_type'   => 'page',
     
    672672
    673673    public function test_get_page_with_password() {
    674         $page_id = $this->factory->post->create(
     674        $page_id = self::factory()->post->create(
    675675            array(
    676676                'post_type'     => 'page',
     
    690690
    691691    public function test_get_page_with_password_using_password() {
    692         $page_id = $this->factory->post->create(
     692        $page_id = self::factory()->post->create(
    693693            array(
    694694                'post_type'     => 'page',
     
    712712
    713713    public function test_get_page_with_password_using_incorrect_password() {
    714         $page_id = $this->factory->post->create(
     714        $page_id = self::factory()->post->create(
    715715            array(
    716716                'post_type'     => 'page',
     
    728728
    729729    public function test_get_page_with_password_without_permission() {
    730         $page_id  = $this->factory->post->create(
     730        $page_id  = self::factory()->post->create(
    731731            array(
    732732                'post_type'     => 'page',
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r51657 r54090  
    254254    protected function grant_write_permission() {
    255255        // Ensure we have write permission.
    256         $user = $this->factory->user->create(
     256        $user = self::factory()->user->create(
    257257            array(
    258258                'role' => 'editor',
  • trunk/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php

    r51367 r54090  
    4444
    4545    public function test_get_items_logged_in() {
    46         $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
     46        $user_id = self::factory()->user->create( array( 'role' => 'author' ) );
    4747        wp_set_current_user( $user_id );
    4848
     
    7373
    7474    public function test_get_item() {
    75         $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
     75        $user_id = self::factory()->user->create( array( 'role' => 'author' ) );
    7676        wp_set_current_user( $user_id );
    7777        $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' );
     
    9595
    9696    public function test_get_item_invalid_internal() {
    97         $user_id = $this->factory->user->create();
     97        $user_id = self::factory()->user->create();
    9898        wp_set_current_user( $user_id );
    9999
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r51962 r54090  
    9595
    9696    public function test_get_item_edit_context() {
    97         $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );
     97        $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    9898        wp_set_current_user( $editor_id );
    9999        $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' );
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r54088 r54090  
    274274
    275275    public function test_get_items_author_query() {
    276         $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
    277         $this->factory->post->create( array( 'post_author' => self::$author_id ) );
     276        self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
     277        self::factory()->post->create( array( 'post_author' => self::$author_id ) );
    278278
    279279        $total_posts = self::$total_posts + 2;
     
    306306
    307307    public function test_get_items_author_exclude_query() {
    308         $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
    309         $this->factory->post->create( array( 'post_author' => self::$author_id ) );
     308        self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
     309        self::factory()->post->create( array( 'post_author' => self::$author_id ) );
    310310
    311311        $total_posts = self::$total_posts + 2;
     
    348348
    349349    public function test_get_items_include_query() {
    350         $id1 = $this->factory->post->create(
     350        $id1 = self::factory()->post->create(
    351351            array(
    352352                'post_status' => 'publish',
     
    354354            )
    355355        );
    356         $id2 = $this->factory->post->create(
     356        $id2 = self::factory()->post->create(
    357357            array(
    358358                'post_status' => 'publish',
     
    387387
    388388    public function test_get_items_orderby_author_query() {
    389         $id2 = $this->factory->post->create(
     389        $id2 = self::factory()->post->create(
    390390            array(
    391391                'post_status' => 'publish',
     
    393393            )
    394394        );
    395         $id3 = $this->factory->post->create(
     395        $id3 = self::factory()->post->create(
    396396            array(
    397397                'post_status' => 'publish',
     
    399399            )
    400400        );
    401         $id1 = $this->factory->post->create(
     401        $id1 = self::factory()->post->create(
    402402            array(
    403403                'post_status' => 'publish',
     
    422422
    423423    public function test_get_items_orderby_modified_query() {
    424         $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    425         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    426         $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     424        $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     425        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     426        $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    427427
    428428        $this->update_post_modified( $id1, '2016-04-20 4:26:20' );
     
    446446
    447447    public function test_get_items_orderby_parent_query() {
    448         $id1 = $this->factory->post->create(
     448        $id1 = self::factory()->post->create(
    449449            array(
    450450                'post_status' => 'publish',
     
    452452            )
    453453        );
    454         $id2 = $this->factory->post->create(
     454        $id2 = self::factory()->post->create(
    455455            array(
    456456                'post_status' => 'publish',
     
    458458            )
    459459        );
    460         $id3 = $this->factory->post->create(
     460        $id3 = self::factory()->post->create(
    461461            array(
    462462                'post_status' => 'publish',
     
    484484
    485485    public function test_get_items_exclude_query() {
    486         $id1 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    487         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     486        $id1 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     487        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    488488
    489489        $request  = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    514514
    515515    public function test_get_items_search_query() {
    516         $this->factory->post->create(
     516        self::factory()->post->create(
    517517            array(
    518518                'post_title'  => 'Search Result',
     
    536536
    537537    public function test_get_items_slug_query() {
    538         $this->factory->post->create(
     538        self::factory()->post->create(
    539539            array(
    540540                'post_title'  => 'Apple',
     
    542542            )
    543543        );
    544         $this->factory->post->create(
     544        self::factory()->post->create(
    545545            array(
    546546                'post_title'  => 'Banana',
     
    559559
    560560    public function test_get_items_multiple_slugs_array_query() {
    561         $this->factory->post->create(
     561        self::factory()->post->create(
    562562            array(
    563563                'post_title'  => 'Apple',
     
    565565            )
    566566        );
    567         $this->factory->post->create(
     567        self::factory()->post->create(
    568568            array(
    569569                'post_title'  => 'Banana',
     
    571571            )
    572572        );
    573         $this->factory->post->create(
     573        self::factory()->post->create(
    574574            array(
    575575                'post_title'  => 'Peach',
     
    593593
    594594    public function test_get_items_multiple_slugs_string_query() {
    595         $this->factory->post->create(
     595        self::factory()->post->create(
    596596            array(
    597597                'post_title'  => 'Apple',
     
    599599            )
    600600        );
    601         $this->factory->post->create(
     601        self::factory()->post->create(
    602602            array(
    603603                'post_title'  => 'Banana',
     
    605605            )
    606606        );
    607         $this->factory->post->create(
     607        self::factory()->post->create(
    608608            array(
    609609                'post_title'  => 'Peach',
     
    629629        wp_set_current_user( 0 );
    630630
    631         $this->factory->post->create( array( 'post_status' => 'draft' ) );
     631        self::factory()->post->create( array( 'post_status' => 'draft' ) );
    632632
    633633        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    655655        wp_set_current_user( self::$editor_id );
    656656
    657         $this->factory->post->create( array( 'post_status' => 'draft' ) );
    658         $this->factory->post->create( array( 'post_status' => 'private' ) );
    659         $this->factory->post->create( array( 'post_status' => 'publish' ) );
     657        self::factory()->post->create( array( 'post_status' => 'draft' ) );
     658        self::factory()->post->create( array( 'post_status' => 'private' ) );
     659        self::factory()->post->create( array( 'post_status' => 'publish' ) );
    660660
    661661        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    678678        wp_set_current_user( self::$editor_id );
    679679
    680         $this->factory->post->create( array( 'post_status' => 'draft' ) );
    681         $this->factory->post->create( array( 'post_status' => 'pending' ) );
    682         $this->factory->post->create( array( 'post_status' => 'publish' ) );
     680        self::factory()->post->create( array( 'post_status' => 'draft' ) );
     681        self::factory()->post->create( array( 'post_status' => 'pending' ) );
     682        self::factory()->post->create( array( 'post_status' => 'publish' ) );
    683683
    684684        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    710710     */
    711711    public function test_get_items_multiple_statuses_custom_role_one_invalid_query() {
    712         $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );
     712        $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) );
    713713
    714714        wp_set_current_user( self::$private_reader_id );
     
    731731
    732732    public function test_get_items_status_without_permissions() {
    733         $draft_id = $this->factory->post->create(
     733        $draft_id = self::factory()->post->create(
    734734            array(
    735735                'post_status' => 'draft',
     
    751751
    752752    public function test_get_items_order_and_orderby() {
    753         $this->factory->post->create(
     753        self::factory()->post->create(
    754754            array(
    755755                'post_title'  => 'Apple Pie',
     
    757757            )
    758758        );
    759         $this->factory->post->create(
     759        self::factory()->post->create(
    760760            array(
    761761                'post_title'  => 'Apple Sauce',
     
    763763            )
    764764        );
    765         $this->factory->post->create(
     765        self::factory()->post->create(
    766766            array(
    767767                'post_title'  => 'Apple Cobbler',
     
    769769            )
    770770        );
    771         $this->factory->post->create(
     771        self::factory()->post->create(
    772772            array(
    773773                'post_title'  => 'Apple Coffee Cake',
     
    806806
    807807    public function test_get_items_with_orderby_include_without_include_param() {
    808         $this->factory->post->create( array( 'post_status' => 'publish' ) );
     808        self::factory()->post->create( array( 'post_status' => 'publish' ) );
    809809
    810810        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    817817
    818818    public function test_get_items_with_orderby_id() {
    819         $id1 = $this->factory->post->create(
     819        $id1 = self::factory()->post->create(
    820820            array(
    821821                'post_status' => 'publish',
     
    823823            )
    824824        );
    825         $id2 = $this->factory->post->create(
     825        $id2 = self::factory()->post->create(
    826826            array(
    827827                'post_status' => 'publish',
     
    829829            )
    830830        );
    831         $id3 = $this->factory->post->create(
     831        $id3 = self::factory()->post->create(
    832832            array(
    833833                'post_status' => 'publish',
     
    851851
    852852    public function test_get_items_with_orderby_slug() {
    853         $id1 = $this->factory->post->create(
     853        $id1 = self::factory()->post->create(
    854854            array(
    855855                'post_title'  => 'ABC',
     
    858858            )
    859859        );
    860         $id2 = $this->factory->post->create(
     860        $id2 = self::factory()->post->create(
    861861            array(
    862862                'post_title'  => 'XYZ',
     
    882882        $slugs = array( 'burrito', 'taco', 'chalupa' );
    883883        foreach ( $slugs as $slug ) {
    884             $this->factory->post->create(
     884            self::factory()->post->create(
    885885                array(
    886886                    'post_title'  => $slug,
     
    904904
    905905    public function test_get_items_with_orderby_relevance() {
    906         $id1 = $this->factory->post->create(
     906        $id1 = self::factory()->post->create(
    907907            array(
    908908                'post_title'   => 'Title is more relevant',
     
    911911            )
    912912        );
    913         $id2 = $this->factory->post->create(
     913        $id2 = self::factory()->post->create(
    914914            array(
    915915                'post_title'   => 'Title is',
     
    932932
    933933    public function test_get_items_with_orderby_relevance_two_terms() {
    934         $id1 = $this->factory->post->create(
     934        $id1 = self::factory()->post->create(
    935935            array(
    936936                'post_title'   => 'Title is more relevant',
     
    939939            )
    940940        );
    941         $id2 = $this->factory->post->create(
     941        $id2 = self::factory()->post->create(
    942942            array(
    943943                'post_title'   => 'Title is',
     
    10061006    public function test_get_items_tags_exclude_query() {
    10071007        $id1 = self::$post_id;
    1008         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1009         $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1010         $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1008        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1009        $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1010        $id4 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    10111011        $tag = wp_insert_term( 'My Tag', 'post_tag' );
    10121012
     
    10291029    public function test_get_items_tags_and_categories_query() {
    10301030        $id1      = self::$post_id;
    1031         $id2      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1031        $id2      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    10321032        $tag      = wp_insert_term( 'My Tag', 'post_tag' );
    10331033        $category = wp_insert_term( 'My Category', 'category' );
     
    10541054    public function test_get_items_tags_or_categories_query() {
    10551055        $id1      = self::$post_id;
    1056         $id2      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1056        $id2      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    10571057        $tag      = wp_insert_term( 'My Tag', 'post_tag' );
    10581058        $category = wp_insert_term( 'My Category', 'category' );
     
    10761076    public function test_get_items_tags_and_categories_exclude_query() {
    10771077        $id1      = self::$post_id;
    1078         $id2      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1078        $id2      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    10791079        $tag      = wp_insert_term( 'My Tag', 'post_tag' );
    10801080        $category = wp_insert_term( 'My Category', 'category' );
     
    11031103    public function test_get_items_tags_or_categories_exclude_query() {
    11041104        $id1      = end( self::$post_ids );
    1105         $id2      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1106         $id3      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1107         $id4      = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1105        $id2      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1106        $id3      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1107        $id4      = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    11081108        $tag      = wp_insert_term( 'My Tag', 'post_tag' );
    11091109        $category = wp_insert_term( 'My Category', 'category' );
     
    13671367    public function test_get_items_sticky() {
    13681368        $id1 = self::$post_id;
    1369         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1369        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    13701370
    13711371        update_option( 'sticky_posts', array( $id2 ) );
     
    13881388    public function test_get_items_sticky_with_include() {
    13891389        $id1 = self::$post_id;
    1390         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1390        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    13911391
    13921392        update_option( 'sticky_posts', array( $id2 ) );
     
    14561456    public function test_get_items_not_sticky() {
    14571457        $id1 = end( self::$post_ids );
    1458         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1458        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    14591459
    14601460        $total_posts = self::$total_posts + 1;
     
    14781478    public function test_get_items_not_sticky_with_exclude() {
    14791479        $id1 = end( self::$post_ids );
    1480         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1481         $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1480        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1481        $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    14821482
    14831483        $total_posts = self::$total_posts + 2;
     
    15041504    public function test_get_items_not_sticky_with_exclude_no_sticky_posts() {
    15051505        $id1 = self::$post_id;
    1506         $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
    1507         $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
     1506        $id2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1507        $id3 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    15081508
    15091509        $total_posts = self::$total_posts + 2;
     
    15751575        $parent_ids       = array( $parent_id1, $parent_id2 );
    15761576        $attachment_ids   = array();
    1577         $attachment_ids[] = $this->factory->attachment->create_object(
     1577        $attachment_ids[] = self::factory()->attachment->create_object(
    15781578            DIR_TESTDATA . '/images/canola.jpg',
    15791579            $parent_id1,
     
    15841584        );
    15851585
    1586         $attachment_ids[] = $this->factory->attachment->create_object(
     1586        $attachment_ids[] = self::factory()->attachment->create_object(
    15871587            DIR_TESTDATA . '/images/canola.jpg',
    15881588            $parent_id2,
     
    16291629
    16301630        // 3rd page.
    1631         $this->factory->post->create();
     1631        self::factory()->post->create();
    16321632        $total_posts++;
    16331633        $total_pages++;
     
    17081708
    17091709    public function test_get_items_status_draft_permissions() {
    1710         $draft_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );
     1710        $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    17111711
    17121712        // Drafts status query var inaccessible to unauthorized users.
     
    17381738     */
    17391739    public function test_get_items_status_private_permissions() {
    1740         $private_post_id = $this->factory->post->create( array( 'post_status' => 'private' ) );
     1740        $private_post_id = self::factory()->post->create( array( 'post_status' => 'private' ) );
    17411741
    17421742        wp_set_current_user( 0 );
     
    17931793
    17941794    public function test_get_items_valid_date() {
    1795         $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) );
    1796         $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) );
    1797         $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) );
     1795        $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-15T00:00:00Z' ) );
     1796        $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-16T00:00:00Z' ) );
     1797        $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-17T00:00:00Z' ) );
    17981798
    17991799        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    18211821     */
    18221822    public function test_get_items_valid_modified_date() {
    1823         $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) );
    1824         $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) );
    1825         $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) );
     1823        $post1 = self::factory()->post->create( array( 'post_date' => '2016-01-01 00:00:00' ) );
     1824        $post2 = self::factory()->post->create( array( 'post_date' => '2016-01-02 00:00:00' ) );
     1825        $post3 = self::factory()->post->create( array( 'post_date' => '2016-01-03 00:00:00' ) );
    18261826        $this->update_post_modified( $post1, '2016-01-15 00:00:00' );
    18271827        $this->update_post_modified( $post2, '2016-01-16 00:00:00' );
     
    19411941
    19421942    public function test_get_post_draft_status_not_authenticated() {
    1943         $draft_id = $this->factory->post->create(
     1943        $draft_id = self::factory()->post->create(
    19441944            array(
    19451945                'post_status' => 'draft',
     
    19571957    public function test_get_post_draft_edit_context() {
    19581958        $post_content = 'Hello World!';
    1959         $this->factory->post->create(
     1959        self::factory()->post->create(
    19601960            array(
    19611961                'post_title'    => 'Hola',
     
    19661966            )
    19671967        );
    1968         $draft_id = $this->factory->post->create(
     1968        $draft_id = self::factory()->post->create(
    19691969            array(
    19701970                'post_status'  => 'draft',
     
    20322032
    20332033    public function test_get_post_with_password() {
    2034         $post_id = $this->factory->post->create(
     2034        $post_id = self::factory()->post->create(
    20352035            array(
    20362036                'post_password' => '$inthebananastand',
     
    20512051
    20522052    public function test_get_post_with_password_using_password() {
    2053         $post_id = $this->factory->post->create(
     2053        $post_id = self::factory()->post->create(
    20542054            array(
    20552055                'post_password' => '$inthebananastand',
     
    20752075
    20762076    public function test_get_post_with_password_using_incorrect_password() {
    2077         $post_id = $this->factory->post->create(
     2077        $post_id = self::factory()->post->create(
    20782078            array(
    20792079                'post_password' => '$inthebananastand',
     
    20912091
    20922092    public function test_get_post_with_password_without_permission() {
    2093         $post_id = $this->factory->post->create(
     2093        $post_id = self::factory()->post->create(
    20942094            array(
    20952095                'post_password' => '$inthebananastand',
     
    21152115     */
    21162116    public function test_get_post_should_not_have_block_version_when_context_view() {
    2117         $post_id = $this->factory->post->create(
     2117        $post_id = self::factory()->post->create(
    21182118            array(
    21192119                'post_content' => '<!-- wp:core/separator -->',
     
    21352135        wp_set_current_user( self::$editor_id );
    21362136
    2137         $post_id = $this->factory->post->create(
     2137        $post_id = self::factory()->post->create(
    21382138            array(
    21392139                'post_content' => '<!-- wp:core/separator -->',
     
    21562156        wp_set_current_user( self::$editor_id );
    21572157
    2158         $post_id = $this->factory->post->create(
     2158        $post_id = self::factory()->post->create(
    21592159            array(
    21602160                'post_content' => '<hr />',
     
    27842784
    27852785        $file          = DIR_TESTDATA . '/images/canola.jpg';
    2786         $attachment_id = $this->factory->attachment->create_object(
     2786        $attachment_id = self::factory()->attachment->create_object(
    27872787            $file,
    27882788            0,
     
    31883188    public function test_rest_update_post_with_empty_date() {
    31893189        // Create a new test post.
    3190         $post_id = $this->factory->post->create();
     3190        $post_id = self::factory()->post->create();
    31913191
    31923192        wp_set_current_user( self::$editor_id );
     
    34373437        update_option( 'timezone_string', $params['timezone_string'] );
    34383438
    3439         $post_id = $this->factory->post->create( array( 'post_status' => $status ) );
     3439        $post_id = self::factory()->post->create( array( 'post_status' => $status ) );
    34403440
    34413441        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) );
     
    35023502        // Need to set dates using wpdb directly because `wp_update_post` and
    35033503        // `wp_insert_post` have additional validation on dates.
    3504         $post_id = $this->factory->post->create();
     3504        $post_id = self::factory()->post->create();
    35053505        $wpdb->update(
    35063506            $wpdb->posts,
     
    41724172
    41734173    public function test_delete_item() {
    4174         $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
     4174        $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) );
    41754175
    41764176        wp_set_current_user( self::$editor_id );
     
    41874187
    41884188    public function test_delete_item_skip_trash() {
    4189         $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
     4189        $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) );
    41904190
    41914191        wp_set_current_user( self::$editor_id );
     
    42024202
    42034203    public function test_delete_item_already_trashed() {
    4204         $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
     4204        $post_id = self::factory()->post->create( array( 'post_title' => 'Deleted post' ) );
    42054205
    42064206        wp_set_current_user( self::$editor_id );
     
    42234223
    42244224    public function test_delete_post_invalid_post_type() {
    4225         $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     4225        $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    42264226
    42274227        wp_set_current_user( self::$editor_id );
     
    44664466        wp_set_current_user( 1 );
    44674467
    4468         $post_id = $this->factory->post->create();
     4468        $post_id = self::factory()->post->create();
    44694469
    44704470        $request  = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id );
     
    45114511            )
    45124512        );
    4513         $post_id = $this->factory->post->create();
     4513        $post_id = self::factory()->post->create();
    45144514
    45154515        // 'my_custom_int' should appear because ?_fields= isn't set.
     
    49324932        wp_set_current_user( self::$editor_id );
    49334933
    4934         $post_id = $this->factory->post->create(
     4934        $post_id = self::factory()->post->create(
    49354935            array(
    49364936                'post_title'  => 'Permalink Template',
     
    49564956        wp_set_current_user( self::$editor_id );
    49574957
    4958         $post_id = $this->factory->post->create(
     4958        $post_id = self::factory()->post->create(
    49594959            array(
    49604960                'post_title'  => 'Permalink Template',
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r54043 r54090  
    206206        // is not desirable.
    207207
    208         $administrator_id = $this->factory->user->create(
     208        $administrator_id = self::factory()->user->create(
    209209            array(
    210210                'role'          => 'administrator',
     
    216216        wp_set_current_user( $administrator_id );
    217217
    218         $post_id = $this->factory->post->create(
     218        $post_id = self::factory()->post->create(
    219219            array(
    220220                'post_name'    => 'restapi-client-fixture-post',
     
    244244        );
    245245
    246         $page_id = $this->factory->post->create(
     246        $page_id = self::factory()->post->create(
    247247            array(
    248248                'post_type'     => 'page',
     
    274274        );
    275275
    276         $tag_id = $this->factory->tag->create(
     276        $tag_id = self::factory()->tag->create(
    277277            array(
    278278                'name'        => 'REST API Client Fixture: Tag',
     
    282282        );
    283283
    284         $media_id = $this->factory->attachment->create_object(
     284        $media_id = self::factory()->attachment->create_object(
    285285            get_temp_dir() . 'canola.jpg',
    286286            0,
     
    296296        );
    297297
    298         $comment_id = $this->factory->comment->create(
     298        $comment_id = self::factory()->comment->create(
    299299            array(
    300300                'comment_approved'     => 1,
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r53909 r54090  
    140140        $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    141141        // Single.
    142         $tag1     = $this->factory->tag->create( array( 'name' => 'Season 5' ) );
     142        $tag1     = self::factory()->tag->create( array( 'name' => 'Season 5' ) );
    143143        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 );
    144144        $response = rest_get_server()->dispatch( $request );
     
    175175
    176176    public function test_get_items() {
    177         $this->factory->tag->create();
     177        self::factory()->tag->create();
    178178
    179179        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    193193
    194194    public function test_get_items_hide_empty_arg() {
    195         $post_id = $this->factory->post->create();
    196         $tag1    = $this->factory->tag->create( array( 'name' => 'Season 5' ) );
    197         $tag2    = $this->factory->tag->create( array( 'name' => 'The Be Sharps' ) );
     195        $post_id = self::factory()->post->create();
     196        $tag1    = self::factory()->tag->create( array( 'name' => 'Season 5' ) );
     197        $tag2    = self::factory()->tag->create( array( 'name' => 'The Be Sharps' ) );
    198198
    199199        wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' );
     
    214214
    215215    public function test_get_items_include_query() {
    216         $id1 = $this->factory->tag->create();
    217         $id2 = $this->factory->tag->create();
     216        $id1 = self::factory()->tag->create();
     217        $id2 = self::factory()->tag->create();
    218218
    219219        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    240240
    241241    public function test_get_items_exclude_query() {
    242         $id1 = $this->factory->tag->create();
    243         $id2 = $this->factory->tag->create();
     242        $id1 = self::factory()->tag->create();
     243        $id2 = self::factory()->tag->create();
    244244
    245245        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    289289
    290290    public function test_get_items_orderby_args() {
    291         $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );
    292         $tag2 = $this->factory->tag->create( array( 'name' => 'Zucchini' ) );
     291        $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) );
     292        $tag2 = self::factory()->tag->create( array( 'name' => 'Zucchini' ) );
    293293
    294294        /*
     
    325325
    326326    public function test_get_items_orderby_id() {
    327         $tag0 = $this->factory->tag->create( array( 'name' => 'Cantaloupe' ) );
    328         $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );
    329         $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );
     327        $tag0 = self::factory()->tag->create( array( 'name' => 'Cantaloupe' ) );
     328        $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) );
     329        $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) );
    330330
    331331        // Defaults to 'orderby' => 'name', 'order' => 'asc'.
     
    361361
    362362    public function test_get_items_orderby_slugs() {
    363         $this->factory->tag->create( array( 'name' => 'Burrito' ) );
    364         $this->factory->tag->create( array( 'name' => 'Taco' ) );
    365         $this->factory->tag->create( array( 'name' => 'Chalupa' ) );
     363        self::factory()->tag->create( array( 'name' => 'Burrito' ) );
     364        self::factory()->tag->create( array( 'name' => 'Taco' ) );
     365        self::factory()->tag->create( array( 'name' => 'Chalupa' ) );
    366366
    367367        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    377377
    378378    public function test_get_items_post_args() {
    379         $post_id = $this->factory->post->create();
    380         $tag1    = $this->factory->tag->create( array( 'name' => 'DC' ) );
    381         $tag2    = $this->factory->tag->create( array( 'name' => 'Marvel' ) );
    382         $this->factory->tag->create( array( 'name' => 'Dark Horse' ) );
     379        $post_id = self::factory()->post->create();
     380        $tag1    = self::factory()->tag->create( array( 'name' => 'DC' ) );
     381        $tag2    = self::factory()->tag->create( array( 'name' => 'Marvel' ) );
     382        self::factory()->tag->create( array( 'name' => 'Dark Horse' ) );
    383383
    384384        wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' );
     
    401401
    402402    public function test_get_terms_post_args_paging() {
    403         $post_id = $this->factory->post->create();
     403        $post_id = self::factory()->post->create();
    404404
    405405        wp_set_object_terms( $post_id, self::$tag_ids, 'post_tag' );
     
    438438
    439439    public function test_get_items_post_empty() {
    440         $post_id = $this->factory->post->create();
     440        $post_id = self::factory()->post->create();
    441441
    442442        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    453453        $controller = new WP_REST_Terms_Controller( 'batman' );
    454454        $controller->register_routes();
    455         $term1 = $this->factory->term->create(
     455        $term1 = self::factory()->term->create(
    456456            array(
    457457                'name'     => 'Cape',
     
    459459            )
    460460        );
    461         $term2 = $this->factory->term->create(
     461        $term2 = self::factory()->term->create(
    462462            array(
    463463                'name'     => 'Mask',
     
    465465            )
    466466        );
    467         $this->factory->term->create(
     467        self::factory()->term->create(
    468468            array(
    469469                'name'     => 'Car',
     
    471471            )
    472472        );
    473         $post_id = $this->factory->post->create();
     473        $post_id = self::factory()->post->create();
    474474
    475475        wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' );
     
    486486
    487487    public function test_get_items_search_args() {
    488         $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );
    489         $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );
     488        $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) );
     489        $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) );
    490490
    491491        /*
     
    510510
    511511    public function test_get_items_slug_arg() {
    512         $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );
    513         $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );
     512        $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) );
     513        $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) );
    514514
    515515        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    523523
    524524    public function test_get_items_slug_array_arg() {
    525         $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );
    526         $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );
    527         $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );
    528         $this->factory->tag->create( array( 'name' => 'Pizza' ) );
     525        $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) );
     526        $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) );
     527        $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) );
     528        self::factory()->tag->create( array( 'name' => 'Pizza' ) );
    529529
    530530        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    546546
    547547    public function test_get_items_slug_csv_arg() {
    548         $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );
    549         $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );
    550         $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );
    551         $this->factory->tag->create( array( 'name' => 'Pizza' ) );
     548        $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) );
     549        $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) );
     550        $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) );
     551        self::factory()->tag->create( array( 'name' => 'Pizza' ) );
    552552
    553553        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    563563    public function test_get_terms_private_taxonomy() {
    564564        register_taxonomy( 'robin', 'post', array( 'public' => false ) );
    565         $term1 = $this->factory->term->create(
     565        $term1 = self::factory()->term->create(
    566566            array(
    567567                'name'     => 'Cape',
     
    569569            )
    570570        );
    571         $term2 = $this->factory->term->create(
     571        $term2 = self::factory()->term->create(
    572572            array(
    573573                'name'     => 'Mask',
     
    601601
    602602        // 3rd page.
    603         $this->factory->tag->create();
     603        self::factory()->tag->create();
    604604        $total_tags++;
    605605        $total_pages++;
     
    666666
    667667    public function test_get_item() {
    668         $id = $this->factory->tag->create();
     668        $id = self::factory()->tag->create();
    669669
    670670        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
     
    677677     */
    678678    public function test_get_item_meta() {
    679         $id = $this->factory->tag->create();
     679        $id = self::factory()->tag->create();
    680680
    681681        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
     
    699699     */
    700700    public function test_get_item_meta_registered_for_different_taxonomy() {
    701         $id = $this->factory->tag->create();
     701        $id = self::factory()->tag->create();
    702702
    703703        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
     
    717717
    718718    public function test_get_item_invalid_permission_for_context() {
    719         $id = $this->factory->tag->create();
     719        $id = self::factory()->tag->create();
    720720
    721721        wp_set_current_user( 0 );
     
    729729    public function test_get_term_private_taxonomy() {
    730730        register_taxonomy( 'robin', 'post', array( 'public' => false ) );
    731         $term1 = $this->factory->term->create(
     731        $term1 = self::factory()->term->create(
    732732            array(
    733733                'name'     => 'Cape',
     
    743743    public function test_get_item_incorrect_taxonomy() {
    744744        register_taxonomy( 'robin', 'post' );
    745         $term1 = $this->factory->term->create(
     745        $term1 = self::factory()->term->create(
    746746            array(
    747747                'name'     => 'Cape',
     
    834834        wp_set_current_user( self::$administrator );
    835835
    836         $existing_tag_id = $this->factory->tag->create( array( 'name' => 'My Not So Awesome Term' ) );
     836        $existing_tag_id = self::factory()->tag->create( array( 'name' => 'My Not So Awesome Term' ) );
    837837
    838838        $request = new WP_REST_Request( 'POST', '/wp/v2/tags' );
     
    859859        );
    860860
    861         $term = get_term_by( 'id', $this->factory->tag->create( $orig_args ), 'post_tag' );
     861        $term = get_term_by( 'id', self::factory()->tag->create( $orig_args ), 'post_tag' );
    862862
    863863        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
     
    887887        wp_set_current_user( self::$administrator );
    888888
    889         $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     889        $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    890890
    891891        $request  = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id );
     
    915915        wp_set_current_user( self::$subscriber );
    916916
    917         $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     917        $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    918918
    919919        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
     
    929929        wp_set_current_user( self::$subscriber );
    930930
    931         $term = $this->factory->tag->create_and_get();
     931        $term = self::factory()->tag->create_and_get();
    932932
    933933        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
     
    956956        wp_set_current_user( self::$administrator );
    957957
    958         $term = $this->factory->tag->create_and_get();
     958        $term = self::factory()->tag->create_and_get();
    959959
    960960        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
     
    978978        wp_set_current_user( self::$administrator );
    979979
    980         $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     980        $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    981981
    982982        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
     
    11051105        wp_set_current_user( self::$administrator );
    11061106
    1107         $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
     1107        $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
    11081108
    11091109        $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
     
    11191119        wp_set_current_user( self::$administrator );
    11201120
    1121         $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
     1121        $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
    11221122
    11231123        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
     
    11411141        wp_set_current_user( self::$subscriber );
    11421142
    1143         $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     1143        $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    11441144
    11451145        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
     
    11541154        wp_set_current_user( self::$subscriber );
    11551155
    1156         $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
     1156        $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
    11571157
    11581158        $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
     
    11821182        wp_set_current_user( self::$administrator );
    11831183
    1184         $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
     1184        $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );
    11851185
    11861186        $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
     
    12021202
    12031203    public function test_prepare_item() {
    1204         $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     1204        $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    12051205
    12061206        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $term->term_id );
     
    12151215        $endpoint = new WP_REST_Terms_Controller( 'post_tag' );
    12161216        $request->set_param( '_fields', 'id,name' );
    1217         $term     = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     1217        $term     = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' );
    12181218        $response = $endpoint->prepare_item_for_response( $term, $request );
    12191219        $this->assertSame(
     
    12771277        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    12781278
    1279         $tag_id = $this->factory->tag->create();
     1279        $tag_id = self::factory()->tag->create();
    12801280
    12811281        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $tag_id );
     
    13071307        wp_set_current_user( self::$administrator );
    13081308
    1309         $tag_id = $this->factory->tag->create();
     1309        $tag_id = self::factory()->tag->create();
    13101310
    13111311        // Check for error on update.
     
    13311331        global $wpdb;
    13321332
    1333         $tags = $this->factory->tag->create_many( 2 );
    1334         $p    = $this->factory->post->create();
     1333        $tags = self::factory()->tag->create_many( 2 );
     1334        $p    = self::factory()->post->create();
    13351335        wp_set_object_terms( $p, $tags[0], 'post_tag' );
    13361336
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r52079 r54090  
    113113
    114114    public function test_get_item_edit_context() {
    115         $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) );
     115        $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    116116        wp_set_current_user( $editor_id );
    117117        $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/category' );
  • trunk/tests/phpunit/tests/rest-api/rest-term-meta-fields.php

    r51571 r54090  
    201201    protected function grant_write_permission() {
    202202        // Ensure we have write permission.
    203         $user = $this->factory->user->create(
     203        $user = self::factory()->user->create(
    204204            array(
    205205                'role' => 'editor',
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r53948 r54090  
    341341
    342342        // 3rd page.
    343         $this->factory->user->create();
     343        self::factory()->user->create();
    344344        $total_users++;
    345345        $total_pages++;
     
    433433        wp_set_current_user( self::$user );
    434434
    435         $low_id  = $this->factory->user->create( array( 'display_name' => 'AAAAA' ) );
    436         $mid_id  = $this->factory->user->create( array( 'display_name' => 'NNNNN' ) );
    437         $high_id = $this->factory->user->create( array( 'display_name' => 'ZZZZ' ) );
     435        $low_id  = self::factory()->user->create( array( 'display_name' => 'AAAAA' ) );
     436        $mid_id  = self::factory()->user->create( array( 'display_name' => 'NNNNN' ) );
     437        $high_id = self::factory()->user->create( array( 'display_name' => 'ZZZZ' ) );
    438438
    439439        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    457457        wp_set_current_user( self::$user );
    458458
    459         $low_id  = $this->factory->user->create( array( 'user_url' => 'http://a.com' ) );
    460         $high_id = $this->factory->user->create( array( 'user_url' => 'http://b.com' ) );
     459        $low_id  = self::factory()->user->create( array( 'user_url' => 'http://a.com' ) );
     460        $high_id = self::factory()->user->create( array( 'user_url' => 'http://b.com' ) );
    461461
    462462        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    482482        wp_set_current_user( self::$user );
    483483
    484         $high_id = $this->factory->user->create( array( 'user_nicename' => 'blogin' ) );
    485         $low_id  = $this->factory->user->create( array( 'user_nicename' => 'alogin' ) );
     484        $high_id = self::factory()->user->create( array( 'user_nicename' => 'blogin' ) );
     485        $low_id  = self::factory()->user->create( array( 'user_nicename' => 'alogin' ) );
    486486
    487487        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    507507        wp_set_current_user( self::$user );
    508508
    509         $this->factory->user->create( array( 'user_nicename' => 'burrito' ) );
    510         $this->factory->user->create( array( 'user_nicename' => 'taco' ) );
    511         $this->factory->user->create( array( 'user_nicename' => 'chalupa' ) );
     509        self::factory()->user->create( array( 'user_nicename' => 'burrito' ) );
     510        self::factory()->user->create( array( 'user_nicename' => 'taco' ) );
     511        self::factory()->user->create( array( 'user_nicename' => 'chalupa' ) );
    512512
    513513        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    525525        wp_set_current_user( self::$user );
    526526
    527         $high_id = $this->factory->user->create( array( 'user_email' => 'bemail@gmail.com' ) );
    528         $low_id  = $this->factory->user->create( array( 'user_email' => 'aemail@gmail.com' ) );
     527        $high_id = self::factory()->user->create( array( 'user_email' => 'bemail@gmail.com' ) );
     528        $low_id  = self::factory()->user->create( array( 'user_email' => 'aemail@gmail.com' ) );
    529529
    530530        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    605605        wp_set_current_user( self::$user );
    606606
    607         $id1 = $this->factory->user->create();
    608         $id2 = $this->factory->user->create();
     607        $id1 = self::factory()->user->create();
     608        $id2 = self::factory()->user->create();
    609609
    610610        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    641641        wp_set_current_user( self::$user );
    642642
    643         $id1 = $this->factory->user->create();
    644         $id2 = $this->factory->user->create();
     643        $id1 = self::factory()->user->create();
     644        $id2 = self::factory()->user->create();
    645645
    646646        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    673673        $this->assertCount( 0, $response->get_data() );
    674674
    675         $yolo_id = $this->factory->user->create( array( 'display_name' => 'yololololo' ) );
     675        $yolo_id = self::factory()->user->create( array( 'display_name' => 'yololololo' ) );
    676676
    677677        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    680680        $this->assertCount( 1, $response->get_data() );
    681681        // Default to wildcard search.
    682         $adam_id = $this->factory->user->create(
     682        $adam_id = self::factory()->user->create(
    683683            array(
    684684                'role'          => 'author',
     
    698698        wp_set_current_user( self::$user );
    699699
    700         $this->factory->user->create(
     700        self::factory()->user->create(
    701701            array(
    702702                'display_name' => 'foo',
     
    704704            )
    705705        );
    706         $id2 = $this->factory->user->create(
     706        $id2 = self::factory()->user->create(
    707707            array(
    708708                'display_name' => 'Moo',
     
    722722        wp_set_current_user( self::$user );
    723723
    724         $id1 = $this->factory->user->create(
     724        $id1 = self::factory()->user->create(
    725725            array(
    726726                'display_name' => 'Taco',
     
    728728            )
    729729        );
    730         $id2 = $this->factory->user->create(
     730        $id2 = self::factory()->user->create(
    731731            array(
    732732                'display_name' => 'Enchilada',
     
    734734            )
    735735        );
    736         $id3 = $this->factory->user->create(
     736        $id3 = self::factory()->user->create(
    737737            array(
    738738                'display_name' => 'Burrito',
     
    740740            )
    741741        );
    742         $this->factory->user->create(
     742        self::factory()->user->create(
    743743            array(
    744744                'display_name' => 'Hon Pizza',
     
    768768        wp_set_current_user( self::$user );
    769769
    770         $id1 = $this->factory->user->create(
     770        $id1 = self::factory()->user->create(
    771771            array(
    772772                'display_name' => 'Taco',
     
    774774            )
    775775        );
    776         $id2 = $this->factory->user->create(
     776        $id2 = self::factory()->user->create(
    777777            array(
    778778                'display_name' => 'Enchilada',
     
    780780            )
    781781        );
    782         $id3 = $this->factory->user->create(
     782        $id3 = self::factory()->user->create(
    783783            array(
    784784                'display_name' => 'Burrito',
     
    786786            )
    787787        );
    788         $this->factory->user->create(
     788        self::factory()->user->create(
    789789            array(
    790790                'display_name' => 'Hon Pizza',
     
    963963
    964964    public function test_get_item() {
    965         $user_id = $this->factory->user->create();
     965        $user_id = self::factory()->user->create();
    966966
    967967        wp_set_current_user( self::$user );
     
    10301030        $this->allow_user_to_manage_multisite();
    10311031
    1032         $lolz = $this->factory->user->create(
     1032        $lolz = self::factory()->user->create(
    10331033            array(
    10341034                'display_name' => 'lolz',
     
    11151115
    11161116    public function test_get_item_published_author_post() {
    1117         $author_id = $this->factory->user->create(
     1117        $author_id = self::factory()->user->create(
    11181118            array(
    11191119                'role' => 'author',
     
    11211121        );
    11221122
    1123         $post_id = $this->factory->post->create(
     1123        $post_id = self::factory()->post->create(
    11241124            array(
    11251125                'post_author' => $author_id,
     
    11351135
    11361136    public function test_get_item_published_author_pages() {
    1137         $author_id = $this->factory->user->create(
     1137        $author_id = self::factory()->user->create(
    11381138            array(
    11391139                'role' => 'author',
     
    11471147        $this->assertSame( 401, $response->get_status() );
    11481148
    1149         $post_id = $this->factory->post->create(
     1149        $post_id = self::factory()->post->create(
    11501150            array(
    11511151                'post_author' => $author_id,
     
    11591159
    11601160    public function test_get_user_with_edit_context() {
    1161         $user_id = $this->factory->user->create();
     1161        $user_id = self::factory()->user->create();
    11621162
    11631163        $this->allow_user_to_manage_multisite();
     
    11701170
    11711171    public function test_get_item_published_author_wrong_context() {
    1172         $author_id = $this->factory->user->create(
     1172        $author_id = self::factory()->user->create(
    11731173            array(
    11741174                'role' => 'author',
     
    11761176        );
    11771177
    1178         $post_id = $this->factory->post->create(
     1178        $post_id = self::factory()->post->create(
    11791179            array(
    11801180                'post_author' => $author_id,
     
    15551555
    15561556    public function test_update_item() {
    1557         $user_id = $this->factory->user->create(
     1557        $user_id = self::factory()->user->create(
    15581558            array(
    15591559                'user_email' => 'test@example.com',
     
    16211621
    16221622    public function test_update_item_existing_email() {
    1623         $user1 = $this->factory->user->create(
     1623        $user1 = self::factory()->user->create(
    16241624            array(
    16251625                'user_login' => 'test_json_user',
     
    16271627            )
    16281628        );
    1629         $user2 = $this->factory->user->create(
     1629        $user2 = self::factory()->user->create(
    16301630            array(
    16311631                'user_login' => 'test_json_user2',
     
    16851685
    16861686    public function test_update_item_invalid_locale() {
    1687         $user1 = $this->factory->user->create(
     1687        $user1 = self::factory()->user->create(
    16881688            array(
    16891689                'user_login' => 'test_json_user',
     
    17041704
    17051705    public function test_update_item_en_US_locale() {
    1706         $user_id = $this->factory->user->create(
     1706        $user_id = self::factory()->user->create(
    17071707            array(
    17081708                'user_login' => 'test_json_user',
     
    17281728     */
    17291729    public function test_update_item_empty_locale() {
    1730         $user_id = $this->factory->user->create(
     1730        $user_id = self::factory()->user->create(
    17311731            array(
    17321732                'user_login' => 'test_json_user',
     
    17521752
    17531753    public function test_update_item_username_attempt() {
    1754         $user1 = $this->factory->user->create(
     1754        $user1 = self::factory()->user->create(
    17551755            array(
    17561756                'user_login' => 'test_json_user',
     
    17581758            )
    17591759        );
    1760         $user2 = $this->factory->user->create(
     1760        $user2 = self::factory()->user->create(
    17611761            array(
    17621762                'user_login' => 'test_json_user2',
     
    17771777
    17781778    public function test_update_item_existing_nicename() {
    1779         $user1 = $this->factory->user->create(
     1779        $user1 = self::factory()->user->create(
    17801780            array(
    17811781                'user_login' => 'test_json_user',
     
    17831783            )
    17841784        );
    1785         $user2 = $this->factory->user->create(
     1785        $user2 = self::factory()->user->create(
    17861786            array(
    17871787                'user_login' => 'test_json_user2',
     
    18021802
    18031803    public function test_json_update_user() {
    1804         $user_id = $this->factory->user->create(
     1804        $user_id = self::factory()->user->create(
    18051805            array(
    18061806                'user_email' => 'testjson2@example.com',
     
    18471847
    18481848    public function test_update_user_role() {
    1849         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     1849        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    18501850
    18511851        wp_set_current_user( self::$user );
     
    18681868
    18691869    public function test_update_user_multiple_roles() {
    1870         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     1870        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    18711871
    18721872        wp_set_current_user( self::$user );
     
    19141914     */
    19151915    public function test_update_user_role_invalid_privilege_deescalation() {
    1916         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     1916        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    19171917
    19181918        wp_set_current_user( $user_id );
     
    19431943     */
    19441944    public function test_update_user_role_privilege_deescalation_multisite() {
    1945         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     1945        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    19461946
    19471947        wp_set_current_user( $user_id );
     
    19571957        $this->assertNotEquals( 'administrator', $new_data['roles'][0] );
    19581958
    1959         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     1959        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    19601960
    19611961        wp_set_current_user( $user_id );
     
    20472047     */
    20482048    public function test_update_item_only_roles_as_editor() {
    2049         $user_id = $this->factory->user->create(
     2049        $user_id = self::factory()->user->create(
    20502050            array(
    20512051                'role' => 'author',
     
    20652065     */
    20662066    public function test_update_item_only_roles_as_site_administrator() {
    2067         $user_id = $this->factory->user->create(
     2067        $user_id = self::factory()->user->create(
    20682068            array(
    20692069                'role' => 'author',
     
    20862086     */
    20872087    public function test_update_item_including_roles_and_other_params() {
    2088         $user_id = $this->factory->user->create(
     2088        $user_id = self::factory()->user->create(
    20892089            array(
    20902090                'role' => 'author',
     
    23422342
    23432343    public function test_delete_item() {
    2344         $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );
     2344        $user_id = self::factory()->user->create( array( 'display_name' => 'Deleted User' ) );
    23452345
    23462346        $this->allow_user_to_manage_multisite();
     
    23672367
    23682368    public function test_delete_item_no_trash() {
    2369         $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );
     2369        $user_id = self::factory()->user->create( array( 'display_name' => 'Deleted User' ) );
    23702370
    23712371        $this->allow_user_to_manage_multisite();
     
    23972397
    23982398    public function test_delete_current_item() {
    2399         $user_id = $this->factory->user->create(
     2399        $user_id = self::factory()->user->create(
    24002400            array(
    24012401                'role'         => 'administrator',
     
    24262426
    24272427    public function test_delete_current_item_no_trash() {
    2428         $user_id = $this->factory->user->create(
     2428        $user_id = self::factory()->user->create(
    24292429            array(
    24302430                'role'         => 'administrator',
     
    24592459
    24602460    public function test_delete_user_without_permission() {
    2461         $user_id = $this->factory->user->create();
     2461        $user_id = self::factory()->user->create();
    24622462
    24632463        $this->allow_user_to_manage_multisite();
     
    24972497
    24982498        // Test with a new user, to avoid any complications.
    2499         $user_id     = $this->factory->user->create();
    2500         $reassign_id = $this->factory->user->create();
    2501         $test_post   = $this->factory->post->create(
     2499        $user_id     = self::factory()->user->create();
     2500        $reassign_id = self::factory()->user->create();
     2501        $test_post   = self::factory()->post->create(
    25022502            array(
    25032503                'post_author' => $user_id,
     
    25312531
    25322532    public function test_delete_user_invalid_reassign_id() {
    2533         $user_id = $this->factory->user->create();
     2533        $user_id = self::factory()->user->create();
    25342534
    25352535        $this->allow_user_to_manage_multisite();
     
    25522552
    25532553    public function test_delete_user_invalid_reassign_passed_as_string() {
    2554         $user_id = $this->factory->user->create();
     2554        $user_id = self::factory()->user->create();
    25552555
    25562556        $this->allow_user_to_manage_multisite();
     
    25672567
    25682568    public function test_delete_user_reassign_passed_as_boolean_false_trashes_post() {
    2569         $user_id = $this->factory->user->create();
    2570 
    2571         $this->allow_user_to_manage_multisite();
    2572 
    2573         wp_set_current_user( self::$user );
    2574 
    2575         $test_post = $this->factory->post->create(
     2569        $user_id = self::factory()->user->create();
     2570
     2571        $this->allow_user_to_manage_multisite();
     2572
     2573        wp_set_current_user( self::$user );
     2574
     2575        $test_post = self::factory()->post->create(
    25762576            array(
    25772577                'post_author' => $user_id,
     
    25952595
    25962596    public function test_delete_user_reassign_passed_as_string_false_trashes_post() {
    2597         $user_id = $this->factory->user->create();
    2598 
    2599         $this->allow_user_to_manage_multisite();
    2600 
    2601         wp_set_current_user( self::$user );
    2602 
    2603         $test_post = $this->factory->post->create(
     2597        $user_id = self::factory()->user->create();
     2598
     2599        $this->allow_user_to_manage_multisite();
     2600
     2601        wp_set_current_user( self::$user );
     2602
     2603        $test_post = self::factory()->post->create(
    26042604            array(
    26052605                'post_author' => $user_id,
     
    26232623
    26242624    public function test_delete_user_reassign_passed_as_empty_string_trashes_post() {
    2625         $user_id = $this->factory->user->create();
    2626 
    2627         $this->allow_user_to_manage_multisite();
    2628 
    2629         wp_set_current_user( self::$user );
    2630 
    2631         $test_post = $this->factory->post->create(
     2625        $user_id = self::factory()->user->create();
     2626
     2627        $this->allow_user_to_manage_multisite();
     2628
     2629        wp_set_current_user( self::$user );
     2630
     2631        $test_post = self::factory()->post->create(
    26322632            array(
    26332633                'post_author' => $user_id,
     
    26512651
    26522652    public function test_delete_user_reassign_passed_as_0_reassigns_author() {
    2653         $user_id = $this->factory->user->create();
    2654 
    2655         $this->allow_user_to_manage_multisite();
    2656 
    2657         wp_set_current_user( self::$user );
    2658 
    2659         $test_post = $this->factory->post->create(
     2653        $user_id = self::factory()->user->create();
     2654
     2655        $this->allow_user_to_manage_multisite();
     2656
     2657        wp_set_current_user( self::$user );
     2658
     2659        $test_post = self::factory()->post->create(
    26602660            array(
    26612661                'post_author' => $user_id,
     
    28322832    public function test_get_item_from_different_site_as_site_administrator() {
    28332833        switch_to_blog( self::$site );
    2834         $user_id = $this->factory->user->create(
     2834        $user_id = self::factory()->user->create(
    28352835            array(
    28362836                'role' => 'author',
     
    28522852    public function test_get_item_from_different_site_as_network_administrator() {
    28532853        switch_to_blog( self::$site );
    2854         $user_id = $this->factory->user->create(
     2854        $user_id = self::factory()->user->create(
    28552855            array(
    28562856                'role' => 'author',
     
    28722872    public function test_update_item_from_different_site_as_site_administrator() {
    28732873        switch_to_blog( self::$site );
    2874         $user_id = $this->factory->user->create(
     2874        $user_id = self::factory()->user->create(
    28752875            array(
    28762876                'role' => 'author',
     
    28942894    public function test_update_item_from_different_site_as_network_administrator() {
    28952895        switch_to_blog( self::$site );
    2896         $user_id = $this->factory->user->create(
     2896        $user_id = self::factory()->user->create(
    28972897            array(
    28982898                'role' => 'author',
     
    29162916    public function test_delete_item_from_different_site_as_site_administrator() {
    29172917        switch_to_blog( self::$site );
    2918         $user_id = $this->factory->user->create(
     2918        $user_id = self::factory()->user->create(
    29192919            array(
    29202920                'role' => 'author',
     
    29382938    public function test_delete_item_from_different_site_as_network_administrator() {
    29392939        switch_to_blog( self::$site );
    2940         $user_id = $this->factory->user->create(
     2940        $user_id = self::factory()->user->create(
    29412941            array(
    29422942                'role' => 'author',
  • trunk/tests/phpunit/tests/rest-api/wpRestMenusController.php

    r52079 r54090  
    8686        );
    8787
    88         $this->menu_id = $this->factory->term->create( $orig_args );
     88        $this->menu_id = self::factory()->term->create( $orig_args );
    8989
    9090        register_meta(
     
    134134        $this->assertSame( array( 'v1' => true ), $data['endpoints'][0]['allow_batch'] );
    135135        // Single.
    136         $tag1     = $this->factory->tag->create( array( 'name' => 'Season 5' ) );
     136        $tag1     = self::factory()->tag->create( array( 'name' => 'Season 5' ) );
    137137        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/menus/' . $tag1 );
    138138        $response = rest_get_server()->dispatch( $request );
  • trunk/tests/phpunit/tests/taxonomy.php

    r54052 r54090  
    682682            )
    683683        );
    684         $t = $this->factory->term->create_and_get(
    685             array(
    686                 'taxonomy' => 'wptests_tax',
    687             )
    688         );
    689 
    690         $p = $this->factory->post->create();
     684        $t = self::factory()->term->create_and_get(
     685            array(
     686                'taxonomy' => 'wptests_tax',
     687            )
     688        );
     689
     690        $p = self::factory()->post->create();
    691691        wp_set_object_terms( $p, $t->slug, 'wptests_tax' );
    692692
  • trunk/tests/phpunit/tests/term/cache.php

    r52836 r54090  
    245245        global $wpdb;
    246246
    247         $term_id = $this->factory->term->create(
     247        $term_id = self::factory()->term->create(
    248248            array(
    249249                'slug'     => 'burrito',
     
    276276        global $wpdb;
    277277
    278         $term_id = $this->factory->term->create(
     278        $term_id = self::factory()->term->create(
    279279            array(
    280280                'slug'     => 'burrito',
     
    314314        global $wpdb;
    315315
    316         $term_id = $this->factory->term->