Make WordPress Core

Changeset 54088


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

Tests: Correctly use the factory method.

This replaces all non-static calls to the WP_UnitTestCase_Base::factory() method with static function calls, since the method is declared as static.

This is a consistency improvement for the test suite.

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

Props jrf.
See #55652.

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/adminbar.php

    r52010 r54088  
    657657                wp_set_current_user( self::$admin_id );
    658658
    659                 $this->factory()->post->create(
     659                self::factory()->post->create(
    660660                        array(
    661661                                'post_type'   => 'customize_changeset',
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r53561 r54088  
    308308                $uuid = wp_generate_uuid4();
    309309
    310                 $post_id      = $this->factory()->post->create(
     310                $post_id      = self::factory()->post->create(
    311311                        array(
    312312                                'post_name'    => $uuid,
    … …  
    347347        public function test_success_save_post_date() {
    348348                $uuid         = wp_generate_uuid4();
    349                 $post_id      = $this->factory()->post->create(
     349                $post_id      = self::factory()->post->create(
    350350                        array(
    351351                                'post_name'    => $uuid,
    … …  
    447447                $uuid = wp_generate_uuid4();
    448448
    449                 $post_id = $this->factory()->post->create(
     449                $post_id = self::factory()->post->create(
    450450                        array(
    451451                                'post_name'    => $uuid,
    … …  
    615615                $this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );
    616616
    617                 $other_user_id = $this->factory()->user->create();
     617                $other_user_id = self::factory()->user->create();
    618618
    619619                // Create auto-drafts.
    620620                $user_auto_draft_ids = array();
    621621                for ( $i = 0; $i < 3; $i++ ) {
    622                         $user_auto_draft_ids[] = $this->factory()->post->create(
     622                        $user_auto_draft_ids[] = self::factory()->post->create(
    623623                                array(
    624624                                        'post_name'    => wp_generate_uuid4(),
    … …  
    632632                $other_user_auto_draft_ids = array();
    633633                for ( $i = 0; $i < 3; $i++ ) {
    634                         $other_user_auto_draft_ids[] = $this->factory()->post->create(
     634                        $other_user_auto_draft_ids[] = self::factory()->post->create(
    635635                                array(
    636636                                        'post_name'    => wp_generate_uuid4(),
  • trunk/tests/phpunit/tests/ajax/CustomizeMenus.php

    r53571 r54088  
    707707
    708708                // Bad nonce.
    709                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
     709                wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    710710                $_POST                = wp_slash(
    711711                        array(
    … …  
    720720
    721721                // Missing params.
    722                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     722                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    723723                $_POST                = wp_slash(
    724724                        array(
  • trunk/tests/phpunit/tests/auth.php

    r52157 r54088  
    422422                        'user_pass'  => 'password',
    423423                );
    424                 $this->factory()->user->create( $user_args );
     424                self::factory()->user->create( $user_args );
    425425
    426426                $_POST['log'] = $user_args['user_email'];
    … …  
    437437         */
    438438        public function test_application_password_authentication() {
    439                 $user_id = $this->factory()->user->create(
     439                $user_id = self::factory()->user->create(
    440440                        array(
    441441                                'user_login' => 'http_auth_login',
  • trunk/tests/phpunit/tests/blocks/context.php

    r52010 r54088  
    3737                );
    3838
    39                 $post = $this->factory()->post->create_and_get( $args );
     39                $post = self::factory()->post->create_and_get( $args );
    4040                setup_postdata( $post );
    4141        }
  • trunk/tests/phpunit/tests/blocks/editor.php

    r52942 r54088  
    2929                );
    3030
    31                 $post = $this->factory()->post->create_and_get( $args );
     31                $post = self::factory()->post->create_and_get( $args );
    3232
    3333                global $wp_rest_server;
  • trunk/tests/phpunit/tests/comment/checkComment.php

    r53863 r54088  
    139139         */
    140140        public function test_should_return_true_when_comment_previously_approved_is_enabled_and_user_has_previously_approved_comments_with_different_email() {
    141                 $subscriber_id = $this->factory()->user->create(
     141                $subscriber_id = self::factory()->user->create(
    142142                        array(
    143143                                'role'  => 'subscriber',
    … …  
    171171         */
    172172        public function test_should_return_false_when_comment_previously_approved_is_enabled_and_user_does_not_have_a_previously_approved_comment_with_any_email() {
    173                 $subscriber_id = $this->factory()->user->create(
     173                $subscriber_id = self::factory()->user->create(
    174174                        array(
    175175                                'role'  => 'subscriber',
  • trunk/tests/phpunit/tests/customize/control.php

    r52010 r54088  
    2727        public function set_up() {
    2828                parent::set_up();
    29                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     29                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    3030                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    3131                $GLOBALS['wp_customize'] = new WP_Customize_Manager();
    … …  
    139139
    140140                // Ensure that auto-draft pages are included if they are among the nav_menus_created_posts.
    141                 $auto_draft_page_id = $this->factory()->post->create(
     141                $auto_draft_page_id = self::factory()->post->create(
    142142                        array(
    143143                                'post_type'   => 'page',
    … …  
    146146                        )
    147147                );
    148                 $this->factory()->post->create(
     148                self::factory()->post->create(
    149149                        array(
    150150                                'post_type'   => 'page',
    … …  
    153153                        )
    154154                );
    155                 $auto_draft_post_id = $this->factory()->post->create(
     155                $auto_draft_post_id = self::factory()->post->create(
    156156                        array(
    157157                                'post_type'   => 'post',
  • trunk/tests/phpunit/tests/customize/custom-css-setting.php

    r52010 r54088  
    121121
    122122                $original_css      = 'body { color: black; }';
    123                 $post_id           = $this->factory()->post->create(
     123                $post_id           = self::factory()->post->create(
    124124                        array(
    125125                                'post_title'   => $this->setting->stylesheet,
    … …  
    131131                );
    132132                $twentyten_css     = 'body { color: red; }';
    133                 $twentyten_post_id = $this->factory()->post->create(
     133                $twentyten_post_id = self::factory()->post->create(
    134134                        array(
    135135                                'post_title'   => 'twentyten',
    … …  
    274274                $this->assertSame( '/*default*//*filtered*/', $this->setting->value() );
    275275
    276                 $this->factory()->post->create(
     276                self::factory()->post->create(
    277277                        array(
    278278                                'post_title'   => $this->setting->stylesheet,
    … …  
    311311        public function test_update_filter() {
    312312                $original_css = 'body { color:red; }';
    313                 $post_id      = $this->factory()->post->create(
     313                $post_id      = self::factory()->post->create(
    314314                        array(
    315315                                'post_title'   => $this->setting->stylesheet,
  • trunk/tests/phpunit/tests/customize/manager.php

    r53948 r54088  
    163163        public function test_constructor_deferred_changeset_uuid() {
    164164                wp_set_current_user( self::$admin_user_id );
    165                 $other_admin_user_id = $this->factory()->user->create( array( 'role' => 'admin' ) );
     165                $other_admin_user_id = self::factory()->user->create( array( 'role' => 'admin' ) );
    166166
    167167                $data = array(
    … …  
    172172
    173173                $uuid1 = wp_generate_uuid4();
    174                 $this->factory()->post->create(
     174                self::factory()->post->create(
    175175                        array(
    176176                                'post_type'     => 'customize_changeset',
    … …  
    188188                 */
    189189                $uuid2   = wp_generate_uuid4();
    190                 $post_id = $this->factory()->post->create(
     190                $post_id = self::factory()->post->create(
    191191                        array(
    192192                                'post_type'     => 'customize_changeset',
    … …  
    425425        public function test_find_changeset_post_id() {
    426426                $uuid    = wp_generate_uuid4();
    427                 $post_id = $this->factory()->post->create(
     427                $post_id = self::factory()->post->create(
    428428                        array(
    429429                                'post_name'    => $uuid,
    … …  
    455455                $uuid         = wp_generate_uuid4();
    456456                $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    457                 $post_id      = $this->factory()->post->create(
     457                $post_id      = self::factory()->post->create(
    458458                        array(
    459459                                'post_name'    => $uuid,
    … …  
    483483                        'blogdescription' => array( 'value' => 'Greet the world' ),
    484484                );
    485                 $this->factory()->post->create(
     485                self::factory()->post->create(
    486486                        array(
    487487                                'post_name'    => $uuid,
    … …  
    566566                        )
    567567                );
    568                 $existing_published_home_page_id   = $this->factory()->post->create(
     568                $existing_published_home_page_id   = self::factory()->post->create(
    569569                        array(
    570570                                'post_name'   => 'home',
    … …  
    573573                        )
    574574                );
    575                 $existing_auto_draft_about_page_id = $this->factory()->post->create(
     575                $existing_auto_draft_about_page_id = self::factory()->post->create(
    576576                        array(
    577577                                'post_name'   => 'about',
    … …  
    821821                wp_set_current_user( self::$admin_user_id );
    822822
    823                 $existing_published_home_page_id = $this->factory()->post->create(
     823                $existing_published_home_page_id = self::factory()->post->create(
    824824                        array(
    825825                                'post_name'   => 'home',
    … …  
    18791879                        array(
    18801880                                'autosave' => true,
    1881                                 'user_id'  => $this->factory()->user->create( array( 'role' => 'administrator' ) ),
     1881                                'user_id'  => self::factory()->user->create( array( 'role' => 'administrator' ) ),
    18821882                        )
    18831883                );
    … …  
    20322032                $new_sidebar_1 = array_reverse( $new_sidebars_widgets['sidebar-1'] );
    20332033
    2034                 $post_id = $this->factory()->post->create(
     2034                $post_id = self::factory()->post->create(
    20352035                        array(
    20362036                                'post_type'    => 'customize_changeset',
    … …  
    23362336                        ),
    23372337                );
    2338                 $this->factory()->post->create(
     2338                self::factory()->post->create(
    23392339                        array(
    23402340                                'post_type'    => 'customize_changeset',
    … …  
    28312831                $this->assertFalse( $this->manager->has_published_pages() );
    28322832
    2833                 $this->factory()->post->create(
     2833                self::factory()->post->create(
    28342834                        array(
    28352835                                'post_type'   => 'page',
    … …  
    28392839                $this->assertFalse( $this->manager->has_published_pages() );
    28402840
    2841                 $this->factory()->post->create(
     2841                self::factory()->post->create(
    28422842                        array(
    28432843                                'post_type'   => 'page',
    … …  
    28652865                $setting    = $this->manager->get_setting( $setting_id );
    28662866                $this->assertInstanceOf( 'WP_Customize_Filter_Setting', $setting );
    2867                 $auto_draft_page = $this->factory()->post->create(
     2867                $auto_draft_page = self::factory()->post->create(
    28682868                        array(
    28692869                                'post_type'   => 'page',
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r52010 r54088  
    852852        public function test_sanitize_nav_menus_created_posts() {
    853853                $menus                 = new WP_Customize_Nav_Menus( $this->wp_customize );
    854                 $contributor_user_id   = $this->factory()->user->create( array( 'role' => 'contributor' ) );
    855                 $author_user_id        = $this->factory()->user->create( array( 'role' => 'author' ) );
    856                 $administrator_user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) );
    857 
    858                 $contributor_post_id   = $this->factory()->post->create(
     854                $contributor_user_id   = self::factory()->user->create( array( 'role' => 'contributor' ) );
     855                $author_user_id        = self::factory()->user->create( array( 'role' => 'author' ) );
     856                $administrator_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     857
     858                $contributor_post_id   = self::factory()->post->create(
    859859                        array(
    860860                                'post_status' => 'auto-draft',
    … …  
    864864                        )
    865865                );
    866                 $author_post_id        = $this->factory()->post->create(
     866                $author_post_id        = self::factory()->post->create(
    867867                        array(
    868868                                'post_status' => 'auto-draft',
    … …  
    872872                        )
    873873                );
    874                 $administrator_post_id = $this->factory()->post->create(
     874                $administrator_post_id = self::factory()->post->create(
    875875                        array(
    876876                                'post_status' => 'auto-draft',
    … …  
    881881                );
    882882
    883                 $draft_post_id = $this->factory()->post->create(
     883                $draft_post_id = self::factory()->post->create(
    884884                        array(
    885885                                'post_status' => 'draft',
    … …  
    889889                );
    890890
    891                 $private_post_id = $this->factory()->post->create(
     891                $private_post_id = self::factory()->post->create(
    892892                        array(
    893893                                'post_status' => 'private',
    … …  
    991991                $trashed_post_id = $r->ID;
    992992
    993                 $pre_published_post_id = $this->factory()->post->create( array( 'post_status' => 'publish' ) );
     993                $pre_published_post_id = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    994994
    995995                $setting_id = 'nav_menus_created_posts';
  • trunk/tests/phpunit/tests/customize/setting.php

    r52010 r54088  
    138138         */
    139139        public function test_preview_standard_types_non_multidimensional() {
    140                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     140                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    141141                $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
    142142
    … …  
    217217         */
    218218        public function test_preview_standard_types_multidimensional() {
    219                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     219                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    220220                $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
    221221
    … …  
    363363         */
    364364        public function test_preview_custom_type() {
    365                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     365                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    366366                $type                = 'custom_type';
    367367                $post_data_overrides = array(
    … …  
    552552         */
    553553        public function test_is_current_blog_previewed() {
    554                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     554                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    555555                $type       = 'option';
    556556                $name       = 'blogname';
    … …  
    744744         */
    745745        public function test_multidimensional_value_when_previewed() {
    746                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     746                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    747747                WP_Customize_Setting::reset_aggregated_multidimensionals();
    748748
  • trunk/tests/phpunit/tests/feed/rss2.php

    r54050 r54088  
    523523
    524524                // Create a post dated last week.
    525                 $post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
     525                $post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
    526526
    527527                // Create a comment dated yesterday.
    528                 $this->factory()->comment->create(
     528                self::factory()->comment->create(
    529529                        array(
    530530                                'comment_post_ID' => $post_id,
    … …  
    562562
    563563                // Create a post dated last week.
    564                 $post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
     564                $post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
    565565
    566566                // Create a comment dated yesterday.
    567                 $this->factory()->comment->create(
     567                self::factory()->comment->create(
    568568                        array(
    569569                                'comment_post_ID' => $post_id,
    … …  
    602602
    603603                // Create a post dated last week.
    604                 $post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
     604                $post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
    605605
    606606                // Create a comment dated yesterday.
    607                 $this->factory()->comment->create(
     607                self::factory()->comment->create(
    608608                        array(
    609609                                'comment_post_ID' => $post_id,
    … …  
    613613
    614614                // Create a post dated today.
    615                 $this->factory()->post->create( array( 'post_date' => $today ) );
     615                self::factory()->post->create( array( 'post_date' => $today ) );
    616616
    617617                // The Last-Modified header should have the date from today's post when it is the latest update.
  • trunk/tests/phpunit/tests/formatting/excerptRemoveBlocks.php

    r53562 r54088  
    6161        public function set_up() {
    6262                parent::set_up();
    63                 self::$post_id = $this->factory()->post->create(
     63                self::$post_id = self::factory()->post->create(
    6464                        array(
    6565                                'post_excerpt' => '', // Empty excerpt, so it has to be generated.
  • trunk/tests/phpunit/tests/formatting/wpTargetedLinkRel.php

    r53562 r54088  
    9090                $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>';
    9191
    92                 $post = $this->factory()->post->create_and_get(
     92                $post = self::factory()->post->create_and_get(
    9393                        array(
    9494                                'post_content' => $content,
  • trunk/tests/phpunit/tests/general/template.php

    r53774 r54088  
    181181        public function test_customize_preview_wp_site_icon_empty() {
    182182                global $wp_customize;
    183                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     183                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    184184
    185185                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    … …  
    199199        public function test_customize_preview_wp_site_icon_dirty() {
    200200                global $wp_customize;
    201                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
     201                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    202202
    203203                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    … …  
    599599         */
    600600        public function test_get_the_archive_title_is_correct_for_author_queries() {
    601                 $user_with_posts    = $this->factory()->user->create_and_get(
     601                $user_with_posts    = self::factory()->user->create_and_get(
    602602                        array(
    603603                                'role' => 'author',
    604604                        )
    605605                );
    606                 $user_with_no_posts = $this->factory()->user->create_and_get(
     606                $user_with_no_posts = self::factory()->user->create_and_get(
    607607                        array(
    608608                                'role' => 'author',
    … …  
    610610                );
    611611
    612                 $this->factory()->post->create(
     612                self::factory()->post->create(
    613613                        array(
    614614                                'post_author' => $user_with_posts->ID,
  • trunk/tests/phpunit/tests/l10n.php

    r53866 r54088  
    310310                );
    311311
    312                 $post = $this->factory()->post->create_and_get( $args );
     312                $post = self::factory()->post->create_and_get( $args );
    313313                setup_postdata( $post );
    314314
    … …  
    336336                );
    337337
    338                 $post = $this->factory()->post->create_and_get( $args );
     338                $post = self::factory()->post->create_and_get( $args );
    339339                setup_postdata( $post );
    340340
    … …  
    362362                );
    363363
    364                 $post = $this->factory()->post->create_and_get( $args );
     364                $post = self::factory()->post->create_and_get( $args );
    365365                setup_postdata( $post );
    366366
    … …  
    388388                );
    389389
    390                 $post = $this->factory()->post->create_and_get( $args );
     390                $post = self::factory()->post->create_and_get( $args );
    391391                setup_postdata( $post );
    392392
    … …  
    414414                );
    415415
    416                 $post = $this->factory()->post->create_and_get( $args );
     416                $post = self::factory()->post->create_and_get( $args );
    417417                setup_postdata( $post );
    418418
    … …  
    442442                );
    443443
    444                 $this->factory()->post->create( $args );
     444                self::factory()->post->create( $args );
    445445
    446446                $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do&hellip;';
    … …  
    468468                );
    469469
    470                 $post = $this->factory()->post->create( $args );
     470                $post = self::factory()->post->create( $args );
    471471
    472472                $expect = 'Lorem ipsum dolor sit amet, consectetur &hellip;';
    … …  
    494494                );
    495495
    496                 $this->factory()->post->create( $args );
     496                self::factory()->post->create( $args );
    497497
    498498                $expect = str_repeat( 'あ', 40 ) . '&hellip;';
    … …  
    515515                        'comment_content' => $this->long_text,
    516516                );
    517                 $comment_id      = $this->factory()->comment->create( $args );
     517                $comment_id      = self::factory()->comment->create( $args );
    518518                $expect          = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut&hellip;';
    519519                $comment_excerpt = get_comment_excerpt( $comment_id );
    … …  
    535535                        'comment_content' => $this->long_text,
    536536                );
    537                 $comment_id      = $this->factory()->comment->create( $args );
     537                $comment_id      = self::factory()->comment->create( $args );
    538538                $expect          = 'Lorem ipsum dolor sit amet, consectetur &hellip;';
    539539                $comment_excerpt = get_comment_excerpt( $comment_id );
    … …  
    555555                        'comment_content' => str_repeat( 'あ', 200 ),
    556556                );
    557                 $comment_id      = $this->factory()->comment->create( $args );
     557                $comment_id      = self::factory()->comment->create( $args );
    558558                $expect          = str_repeat( 'あ', 40 ) . '&hellip;';
    559559                $comment_excerpt = get_comment_excerpt( $comment_id );
  • trunk/tests/phpunit/tests/l10n/getUserLocale.php

    r53866 r54088  
    1313                parent::set_up();
    1414
    15                 $this->user_id = $this->factory()->user->create(
     15                $this->user_id = self::factory()->user->create(
    1616                        array(
    1717                                'role'   => 'administrator',
    … …  
    8383
    8484        public function test_user_id_argument_with_id() {
    85                 $user_id = $this->factory()->user->create(
     85                $user_id = self::factory()->user->create(
    8686                        array(
    8787                                'locale' => 'es_ES',
    … …  
    100100
    101101        public function test_user_id_argument_with_wp_user_object() {
    102                 $user_id = $this->factory()->user->create(
     102                $user_id = self::factory()->user->create(
    103103                        array(
    104104                                'locale' => 'es_ES',
  • trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php

    r53874 r54088  
    327327                $site_locale = get_locale();
    328328
    329                 $user_id = $this->factory()->user->create(
     329                $user_id = self::factory()->user->create(
    330330                        array(
    331331                                'role'   => 'administrator',
    … …  
    379379                $site_locale = get_locale();
    380380
    381                 $user_id = $this->factory()->user->create(
     381                $user_id = self::factory()->user->create(
    382382                        array(
    383383                                'role'   => 'administrator',
    … …  
    431431                $site_locale = get_locale();
    432432
    433                 $user_id = $this->factory()->user->create(
     433                $user_id = self::factory()->user->create(
    434434                        array(
    435435                                'role'   => 'administrator',
  • trunk/tests/phpunit/tests/multisite/network.php

    r53011 r54088  
    562562                        $this->assertNull( get_network( $new_network_id ) );
    563563
    564                         $new_network = $this->factory()->network->create_and_get();
     564                        $new_network = self::factory()->network->create_and_get();
    565565
    566566                        // Double-check we got the ID of the new network correct.
  • trunk/tests/phpunit/tests/multisite/site.php

    r52010 r54088  
    24602460                        $this->assertNull( get_site( $new_site_id ) );
    24612461
    2462                         $new_site = $this->factory()->blog->create_and_get();
     2462                        $new_site = self::factory()->blog->create_and_get();
    24632463
    24642464                        // Double-check we got the ID of the new site correct.
  • trunk/tests/phpunit/tests/oembed/WpEmbed.php

    r51568 r54088  
    2929
    3030        public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_message() {
    31                 $GLOBALS['post'] = $this->factory()->post->create_and_get(
     31                $GLOBALS['post'] = self::factory()->post->create_and_get(
    3232                        array(
    3333                                'post_title' => 'Hello World',
    … …  
    4242
    4343        public function test_maybe_run_ajax_cache_should_return_javascript() {
    44                 $GLOBALS['post'] = $this->factory()->post->create_and_get(
     44                $GLOBALS['post'] = self::factory()->post->create_and_get(
    4545                        array(
    4646                                'post_title' => 'Hello World',
    … …  
    135135
    136136        public function test_delete_oembed_caches() {
    137                 $post_id = $this->factory()->post->create();
     137                $post_id = self::factory()->post->create();
    138138
    139139                add_post_meta( $post_id, '_oembed_foo', 'bar' );
    … …  
    148148
    149149        public function test_cache_oembed_invalid_post_type() {
    150                 $post_id = $this->factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
     150                $post_id = self::factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
    151151
    152152                $this->wp_embed->cache_oembed( $post_id );
    … …  
    155155
    156156        public function test_cache_oembed_empty_content() {
    157                 $post_id = $this->factory()->post->create( array( 'post_content' => '' ) );
     157                $post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    158158
    159159                $this->wp_embed->cache_oembed( $post_id );
    … …  
    168168                $cachekey_time = '_oembed_time_' . $key_suffix;
    169169
    170                 $post_id = $this->factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
     170                $post_id = self::factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
    171171
    172172                add_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) );
    … …  
    182182                global $post;
    183183
    184                 $post       = $this->factory()->post->create_and_get();
     184                $post       = self::factory()->post->create_and_get();
    185185                $url        = 'https://example.com/';
    186186                $expected   = '<b>Embedded content</b>';
    … …  
    209209                global $post;
    210210
    211                 $post          = $this->factory()->post->create_and_get();
     211                $post          = self::factory()->post->create_and_get();
    212212                $url           = 'https://example.com/';
    213213                $expected      = '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>';
  • trunk/tests/phpunit/tests/oembed/controller.php

    r52010 r54088  
    291291
    292292        public function test_request_invalid_format() {
    293                 $post_id = $this->factory()->post->create();
     293                $post_id = self::factory()->post->create();
    294294
    295295                $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
    … …  
    462462
    463463        public function test_rest_pre_serve_request() {
    464                 $user = $this->factory()->user->create_and_get(
     464                $user = self::factory()->user->create_and_get(
    465465                        array(
    466466                                'display_name' => 'John Doe',
    467467                        )
    468468                );
    469                 $post = $this->factory()->post->create_and_get(
     469                $post = self::factory()->post->create_and_get(
    470470                        array(
    471471                                'post_author' => $user->ID,
    … …  
    486486
    487487        public function test_rest_pre_serve_request_wrong_format() {
    488                 $post = $this->factory()->post->create_and_get();
     488                $post = self::factory()->post->create_and_get();
    489489
    490490                $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
    … …  
    498498
    499499        public function test_rest_pre_serve_request_wrong_method() {
    500                 $post = $this->factory()->post->create_and_get();
     500                $post = self::factory()->post->create_and_get();
    501501
    502502                $request = new WP_REST_Request( 'HEAD', '/oembed/1.0/embed' );
    … …  
    514514                $this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
    515515
    516                 $post_id     = $this->factory()->post->create();
     516                $post_id     = self::factory()->post->create();
    517517                $url         = get_permalink( $post_id );
    518518                $url_encoded = urlencode( $url );
    … …  
    528528                $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
    529529
    530                 $post_id     = $this->factory()->post->create();
     530                $post_id     = self::factory()->post->create();
    531531                $url         = get_permalink( $post_id );
    532532                $url_encoded = urlencode( $url );
  • trunk/tests/phpunit/tests/oembed/headers.php

    r52010 r54088  
    1414         */
    1515        public function test_rest_pre_serve_request_headers() {
    16                 $post = $this->factory()->post->create_and_get(
     16                $post = self::factory()->post->create_and_get(
    1717                        array(
    1818                                'post_title' => 'Hello World',
  • trunk/tests/phpunit/tests/post.php

    r54068 r54088  
    727727        public function test_use_block_editor_for_post() {
    728728                $this->assertFalse( use_block_editor_for_post( -1 ) );
    729                 $bogus_post_id = $this->factory()->post->create(
     729                $bogus_post_id = self::factory()->post->create(
    730730                        array(
    731731                                'post_type' => 'bogus',
    … …  
    740740                        )
    741741                );
    742                 $restless_post_id = $this->factory()->post->create(
     742                $restless_post_id = self::factory()->post->create(
    743743                        array(
    744744                                'post_type' => 'restless',
    … …  
    747747                $this->assertFalse( use_block_editor_for_post( $restless_post_id ) );
    748748
    749                 $generic_post_id = $this->factory()->post->create();
     749                $generic_post_id = self::factory()->post->create();
    750750
    751751                add_filter( 'use_block_editor_for_post', '__return_false' );
  • trunk/tests/phpunit/tests/post/isPostPubliclyViewable.php

    r51587 r54088  
    5555                }
    5656
    57                 $post_id = $this->factory()->post->create(
     57                $post_id = self::factory()->post->create(
    5858                        array(
    5959                                'post_type'   => $post_type,
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r53510 r54088  
    746746         */
    747747        public function test_wp_delete_customize_changeset_dependent_auto_drafts() {
    748                 $auto_draft_post_id = $this->factory()->post->create(
     748                $auto_draft_post_id = self::factory()->post->create(
    749749                        array(
    750750                                'post_status' => 'auto-draft',
    751751                        )
    752752                );
    753                 $draft_post_id      = $this->factory()->post->create(
     753                $draft_post_id      = self::factory()->post->create(
    754754                        array(
    755755                                'post_status' => 'draft',
    756756                        )
    757757                );
    758                 $private_post_id    = $this->factory()->post->create(
     758                $private_post_id    = self::factory()->post->create(
    759759                        array(
    760760                                'post_status' => 'private',
  • trunk/tests/phpunit/tests/post/wpInsertPost.php

    r53883 r54088  
    14261426                wp_set_current_user( self::$user_ids['contributor'] );
    14271427
    1428                 $post_id = $this->factory()->post->create(
     1428                $post_id = self::factory()->post->create(
    14291429                        array(
    14301430                                'post_title'   => 'Jefferson claim: nice to have Washington on your side.',
    … …  
    14651465                wp_set_current_user( self::$user_ids['administrator'] );
    14661466
    1467                 $post_id = $this->factory()->post->create(
     1467                $post_id = self::factory()->post->create(
    14681468                        array(
    14691469                                'post_title'   => 'What is the Conner Project?',
    … …  
    15061506                wp_set_current_user( self::$user_ids['administrator'] );
    15071507
    1508                 $post_id = $this->factory()->post->create(
     1508                $post_id = self::factory()->post->create(
    15091509                        array(
    15101510                                'post_title'   => 'Everything is legal in New Jersey',
    … …  
    15431543                $now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) );
    15441544
    1545                 $post_id = $this->factory()->post->create(
     1545                $post_id = self::factory()->post->create(
    15461546                        array(
    15471547                                'post_date_gmt' => $now->modify( '-1 year' )->format( 'Y-m-d H:i:s' ),
    … …  
    15521552                $this->assertSame( 'publish', get_post_status( $post_id ) );
    15531553
    1554                 $post_id = $this->factory()->post->create(
     1554                $post_id = self::factory()->post->create(
    15551555                        array(
    15561556                                'post_date_gmt' => $now->modify( '+50 years' )->format( 'Y-m-d H:i:s' ),
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r54055 r54088  
    52575257        public function test_draft_post_does_not_have_the_same_slug_as_existing_post() {
    52585258                wp_set_current_user( self::$editor_id );
    5259                 $this->factory()->post->create( array( 'post_name' => 'sample-slug' ) );
     5259                self::factory()->post->create( array( 'post_name' => 'sample-slug' ) );
    52605260
    52615261                $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php

    r54058 r54088  
    137137        public function test_get_items_forbidden() {
    138138                // Set current user without `edit_posts` capability.
    139                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
     139                wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    140140
    141141                $request  = new WP_REST_Request( 'GET', static::REQUEST_ROUTE );
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php

    r54058 r54088  
    163163        public function test_get_items_forbidden() {
    164164                // Set current user without `edit_posts` capability.
    165                 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
     165                wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    166166
    167167                $request  = new WP_REST_Request( 'GET', static::REQUEST_ROUTE );
  • trunk/tests/phpunit/tests/term/isTermPubliclyViewable.php

    r53894 r54088  
    2626         */
    2727        public function test_is_term_publicly_viewable( $taxonomy, $expected ) {
    28                 $term_id = $this->factory()->term->create(
     28                $term_id = self::factory()->term->create(
    2929                        array(
    3030                                'taxonomy' => $taxonomy,
  • trunk/tests/phpunit/tests/term/termCounts.php

    r52010 r54088  
    9191                $term_count = get_term( get_option( 'default_category' ) )->count;
    9292                // Do not use shared fixture for this test as it relies on a new post.
    93                 $post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
     93                $post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
    9494
    9595                $expected = $term_count + $change;
    … …  
    245245                add_filter( 'update_post_term_count_statuses', array( $this, 'add_custom_status_to_counted_statuses' ) );
    246246
    247                 $post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
     247                $post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
    248248                wp_add_object_terms( $post_id, self::$attachment_term, 'wp_test_tax_counts' );
    249249                $attachment_id = self::factory()->attachment->create_object(
    … …  
    297297                $term_count = get_term( self::$attachment_term )->count;
    298298                // Do not use shared fixture for this test as it relies on a new post.
    299                 $post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
     299                $post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
    300300                wp_add_object_terms( $post_id, self::$attachment_term, 'wp_test_tax_counts' );
    301301                $attachment_id = self::factory()->attachment->create_object(
  • trunk/tests/phpunit/tests/theme.php

    r54040 r54088  
    367367         */
    368368        public function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
    369                 $nav_created_post_ids = $this->factory()->post->create_many(
     369                $nav_created_post_ids = self::factory()->post->create_many(
    370370                        2,
    371371                        array(
  • trunk/tests/phpunit/tests/user.php

    r53818 r54088  
    16971697                $was_confirmation_email_sent = false;
    16981698
    1699                 $user = $this->factory()->user->create_and_get(
     1699                $user = self::factory()->user->create_and_get(
    17001700                        array(
    17011701                                'user_email' => 'before@example.com',
    … …  
    17341734                $was_confirmation_email_sent = false;
    17351735
    1736                 $user = $this->factory()->user->create_and_get(
     1736                $user = self::factory()->user->create_and_get(
    17371737                        array(
    17381738                                'user_email' => 'before@example.com',
  • trunk/tests/phpunit/tests/widgets/wpWidgetCustomHtml.php

    r52248 r54088  
    173173
    174174                wp_set_current_user(
    175                         $this->factory()->user->create(
     175                        self::factory()->user->create(
    176176                                array(
    177177                                        'role' => 'administrator',
    … …  
    242242         */
    243243        public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_on() {
    244                 $user = $this->factory()->user->create();
     244                $user = self::factory()->user->create();
    245245                wp_set_current_user( $user );
    246246                wp_get_current_user()->syntax_highlighting = 'true';
    … …  
    263263         */
    264264        public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_off() {
    265                 $user = $this->factory()->user->create();
     265                $user = self::factory()->user->create();
    266266                wp_set_current_user( $user );
    267267                update_user_meta( $user, 'syntax_highlighting', 'false' );
  • trunk/tests/phpunit/tests/widgets/wpWidgetMedia.php

    r52248 r54088  
    117117                global $wp_customize;
    118118                wp_set_current_user(
    119                         $this->factory()->user->create(
     119                        self::factory()->user->create(
    120120                                array(
    121121                                        'role' => 'administrator',
    … …  
    160160                $this->assertFalse( $widget->is_attachment_with_mime_type( -123, 'image' ) );
    161161
    162                 $post_id = $this->factory()->post->create();
     162                $post_id = self::factory()->post->create();
    163163                $this->assertFalse( $widget->is_attachment_with_mime_type( $post_id, 'image' ) );
    164164                $this->assertFalse( $widget->is_attachment_with_mime_type( $attachment_id, 'video' ) );
  • trunk/tests/phpunit/tests/widgets/wpWidgetText.php

    r52010 r54088  
    8282                global $wp_customize;
    8383                wp_set_current_user(
    84                         $this->factory()->user->create(
     84                        self::factory()->user->create(
    8585                                array(
    8686                                        'role' => 'administrator',
    … …  
    316316        public function test_widget_shortcodes() {
    317317                global $post;
    318                 $post_id = $this->factory()->post->create();
     318                $post_id = self::factory()->post->create();
    319319                $post    = get_post( $post_id );
    320320
    … …  
    717717
    718718                wp_set_current_user(
    719                         $this->factory()->user->create(
     719                        self::factory()->user->create(
    720720                                array(
    721721                                        'role' => 'administrator',
Note: See TracChangeset for help on using the changeset viewer.