Make WordPress Core


Ignore:
Timestamp:
12/19/2021 01:42:37 PM (5 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Reduce the use of unnecessary randomness in tests.

This increases the overall reliability of the tests.

Props johnillo

Fixes #37371

File:
1 edited

Legend:

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

    r52010 r52389  
    6969                                'post_author'  => self::$editor_id,
    7070                                'post_status'  => 'publish',
    71                                 'post_content' => rand_str(),
    72                                 'post_title'   => rand_str(),
     71                                'post_content' => "{$post_type}_content",
     72                                'post_title'   => "{$post_type}_title",
    7373                                'tax_input'    => array(
    7474                                        'post_tag' => 'tag1,tag2',
    … …  
    127127                        'post_author'  => self::$editor_id,
    128128                        'post_status'  => 'publish',
    129                         'post_content' => rand_str(),
    130                         'post_title'   => rand_str(),
     129                        'post_content' => 'content',
     130                        'post_title'   => 'title',
    131131                        'post_date'    => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ),
    132132                );
    … …  
    163163                        'post_author'  => self::$editor_id,
    164164                        'post_status'  => 'publish',
    165                         'post_content' => rand_str(),
    166                         'post_title'   => rand_str(),
     165                        'post_content' => 'content',
     166                        'post_title'   => 'title',
    167167                        'post_date'    => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
    168168                );
    … …  
    208208                        'post_author'  => self::$editor_id,
    209209                        'post_status'  => 'publish',
    210                         'post_content' => rand_str(),
    211                         'post_title'   => rand_str(),
     210                        'post_content' => 'content',
     211                        'post_title'   => 'title',
    212212                        'post_date'    => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
    213213                );
    … …  
    250250                        'post_author'  => self::$editor_id,
    251251                        'post_status'  => 'draft',
    252                         'post_content' => rand_str(),
    253                         'post_title'   => rand_str(),
     252                        'post_content' => 'content',
     253                        'post_title'   => 'title',
    254254                        'post_date'    => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ),
    255255                );
    … …  
    285285                        'post_author'  => self::$editor_id,
    286286                        'post_status'  => 'publish',
    287                         'post_content' => rand_str(),
    288                         'post_title'   => rand_str(),
     287                        'post_content' => 'content',
     288                        'post_title'   => 'title',
    289289                        'post_date'    => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
    290290                );
    … …  
    329329                                'post_author'  => self::$editor_id,
    330330                                'post_status'  => 'publish',
    331                                 'post_content' => rand_str(),
    332                                 'post_title'   => rand_str(),
     331                                'post_content' => "{$status}_content",
     332                                'post_title'   => "{$status}_title",
    333333                                'post_date'    => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
    334334                        );
    … …  
    371371                        'post_author'  => self::$editor_id,
    372372                        'post_status'  => 'private',
    373                         'post_content' => rand_str(),
    374                         'post_title'   => rand_str(),
     373                        'post_content' => 'content',
     374                        'post_title'   => 'title',
    375375                        'post_date'    => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ),
    376376                );
    … …  
    405405                        'post_author'  => self::$editor_id,
    406406                        'post_status'  => 'publish',
    407                         'post_content' => rand_str(),
    408                         'post_title'   => rand_str(),
     407                        'post_content' => 'content',
     408                        'post_title'   => 'title',
    409409                        'post_date'    => '2012-02-30 00:00:00',
    410410                );
    … …  
    428428                        'post_author'  => self::$editor_id,
    429429                        'post_status'  => 'publish',
    430                         'post_content' => rand_str(),
    431                         'post_title'   => rand_str(),
     430                        'post_content' => 'content',
     431                        'post_title'   => 'title',
    432432                        'post_date'    => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
    433433                );
    … …  
    534534                        'post_author'  => self::$editor_id,
    535535                        'post_status'  => 'publish',
    536                         'post_content' => rand_str(),
    537                         'post_title'   => rand_str(),
     536                        'post_content' => 'content',
     537                        'post_title'   => 'title',
    538538                        'post_date'    => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ),
    539539                );
    … …  
    565565                        'post_author'  => self::$editor_id,
    566566                        'post_status'  => 'publish',
    567                         'post_content' => rand_str(),
     567                        'post_content' => 'content',
    568568                        'post_title'   => '',
    569569                        'post_date'    => '2007-10-31 06:15:00',
    … …  
    783783                register_taxonomy( 'test_tax', 'post' );
    784784
    785                 $title          = rand_str();
     785                $title          = 'title';
    786786                $post_data      = array(
    787787                        'post_author'  => self::$editor_id,
    788788                        'post_status'  => 'publish',
    789                         'post_content' => rand_str(),
     789                        'post_content' => 'content',
    790790                        'post_title'   => $title,
    791791                        'tax_input'    => array(
    … …  
    907907
    908908                $post = self::factory()->post->create( array( 'post_type' => $post_type ) );
    909                 wp_set_object_terms( $post, rand_str(), $tax );
     909                wp_set_object_terms( $post, 'foo', $tax );
    910910
    911911                $wp_tag_cloud = wp_tag_cloud(
    … …  
    974974                                'post_author'  => self::$editor_id,
    975975                                'post_status'  => 'publish',
    976                                 'post_content' => rand_str(),
    977                                 'post_title'   => rand_str(),
     976                                'post_content' => 'content',
     977                                'post_title'   => 'title',
    978978                        )
    979979                );
    … …  
    992992                                'post_author'  => self::$editor_id,
    993993                                'post_status'  => 'publish',
    994                                 'post_content' => rand_str(),
    995                                 'post_title'   => rand_str(),
     994                                'post_content' => 'content',
     995                                'post_title'   => 'title',
    996996                                'post_type'    => 'page',
    997997                        )
    … …  
    12041204                        'post_author'   => self::$editor_id,
    12051205                        'post_status'   => 'publish',
    1206                         'post_content'  => rand_str(),
    1207                         'post_title'    => rand_str(),
     1206                        'post_content'  => 'content',
     1207                        'post_title'    => 'title',
    12081208                        'post_date_gmt' => '2014-01-01 12:00:00',
    12091209                );
Note: See TracChangeset for help on using the changeset viewer.