Make WordPress Core

Changeset 38938


Ignore:
Timestamp:
10/26/2016 01:23:24 AM (8 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Continue eliminating randomness in tests.

See #37371

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

Legend:

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

    r38810 r38938  
    350350            'post_author' => self::$editor_id,
    351351            'post_status' => 'publish',
    352             'post_content' => rand_str(),
    353             'post_title' => rand_str(),
     352            'post_content' => 'Post Content',
     353            'post_title' => 'Post Title',
    354354        );
    355355        $id = wp_insert_post( $post );
  • trunk/tests/phpunit/tests/post/thumbnails.php

    r38433 r38938  
    282282            'ID'            => self::$post->ID,
    283283            'post_status'   => 'publish',
    284             'post_content'  => rand_str(),
    285             'post_title'    => rand_str(),
     284            'post_content'  => 'Post content',
     285            'post_title'    => 'Post Title',
    286286            '_thumbnail_id' => self::$attachment_id,
    287287        ) );
     
    293293            'ID'            => $post_id,
    294294            'post_status'   => 'publish',
    295             'post_content'  => rand_str(),
    296             'post_title'    => rand_str(),
     295            'post_content'  => 'Post content',
     296            'post_title'    => 'Post Title',
    297297            '_thumbnail_id' => - 1, // -1 removes post thumbnail.
    298298        ) );
     
    310310            'post_type'      => 'attachment',
    311311            'post_status'    => 'inherit',
    312             'post_content'   => rand_str(),
    313             'post_title'     => rand_str(),
     312            'post_content'   => 'Post content',
     313            'post_title'     => 'Post Title',
    314314            'post_mime_type' => 'audio/mpeg',
    315315            'post_parent'    => 0,
     
    325325            'post_type'      => 'attachment',
    326326            'post_status'    => 'inherit',
    327             'post_content'   => rand_str(),
    328             'post_title'     => rand_str(),
     327            'post_content'   => 'Post content',
     328            'post_title'     => 'Post Title',
    329329            'post_mime_type' => 'image/jpeg',
    330330            'post_parent'    => 0,
  • trunk/tests/phpunit/tests/post/wpPostType.php

    r37890 r38938  
    1414
    1515    public function test_add_supports_defaults() {
    16         $post_type        = rand_str();
     16        $post_type        = 'cpt';
    1717        $post_type_object = new WP_Post_Type( $post_type );
    1818
     
    2828
    2929    public function test_add_supports_custom() {
    30         $post_type        = rand_str();
     30        $post_type        = 'cpt';
    3131        $post_type_object = new WP_Post_Type( $post_type, array(
    3232            'supports' => array(
     
    5757        global $wp;
    5858
    59         $post_type        = rand_str();
     59        $post_type        = 'cpt';
    6060        $post_type_object = new WP_Post_Type( $post_type, array( 'rewrite' => false, 'query_var' => 'foobar' ) );
    6161        $post_type_object->add_rewrite_rules();
     
    7070        global $wp;
    7171
    72         $post_type        = rand_str();
     72        $post_type        = 'cpt';
    7373        $post_type_object = new WP_Post_Type( $post_type, array(
    7474            'public'    => true,
     
    9393        global $wp_rewrite;
    9494
    95         $post_type        = rand_str();
     95        $post_type        = 'cpt';
    9696        $post_type_object = new WP_Post_Type( $post_type, array( 'public' => true, 'rewrite' => true ) );
    9797
     
    107107
    108108    public function test_register_meta_boxes() {
    109         $post_type        = rand_str();
     109        $post_type        = 'cpt';
    110110        $post_type_object = new WP_Post_Type( $post_type, array( 'register_meta_box_cb' => '__return_false' ) );
    111111
     
    120120
    121121    public function test_adds_future_post_hook() {
    122         $post_type        = rand_str();
     122        $post_type        = 'cpt';
    123123        $post_type_object = new WP_Post_Type( $post_type );
    124124        $post_type_object->add_hooks();
     
    134134        global $wp_post_types;
    135135
    136         $post_type        = rand_str();
     136        $post_type        = 'cpt';
    137137        $post_type_object = new WP_Post_Type( $post_type, array( 'taxonomies' => array( 'post_tag' ) ) );
    138138
  • trunk/tests/phpunit/tests/post/wpUniquePostSlug.php

    r37443 r38938  
    2828                    'post_author' => $author_id,
    2929                    'post_status' => 'publish',
    30                     'post_content' => rand_str(),
     30                    'post_content' => 'Post content',
    3131                    'post_title' => $post_title,
    3232                );
  • trunk/tests/phpunit/tests/query/conditionals.php

    r38413 r38938  
    5656
    5757    function test_404() {
    58         $this->go_to('/'.rand_str());
     58        $this->go_to( '/notapage' );
    5959        $this->assertQueryTrue('is_404');
    6060    }
  • trunk/tests/phpunit/tests/query/metaQuery.php

    r35242 r38938  
    391391    public function test_meta_query_relation_or() {
    392392        $post_id = self::factory()->post->create();
    393         add_post_meta( $post_id, 'foo', rand_str() );
    394         add_post_meta( $post_id, 'foo', rand_str() );
     393        add_post_meta( $post_id, 'foo', 'foo_val_1' );
     394        add_post_meta( $post_id, 'foo', 'foo_val_2' );
     395
    395396        $post_id2 = self::factory()->post->create();
    396         add_post_meta( $post_id2, 'bar', 'val2' );
     397        add_post_meta( $post_id2, 'bar', 'bar_val_1' );
     398
    397399        $post_id3 = self::factory()->post->create();
    398         add_post_meta( $post_id3, 'baz', rand_str() );
     400        add_post_meta( $post_id3, 'baz', 'baz_val_1' );
     401
    399402        $post_id4 = self::factory()->post->create();
    400         add_post_meta( $post_id4, 'froo', rand_str() );
     403        add_post_meta( $post_id4, 'froo', 'froo_val_1' );
     404
    401405        $post_id5 = self::factory()->post->create();
    402         add_post_meta( $post_id5, 'tango', 'val2' );
     406        add_post_meta( $post_id5, 'tango', 'tango_val_1' );
     407
     408        $post_id6 = self::factory()->post->create();
     409        add_post_meta( $post_id6, 'bar', 'bar_val_2' );
     410
     411        $query = new WP_Query( array(
     412            'update_post_meta_cache' => false,
     413            'update_post_term_cache' => false,
     414            'fields' => 'ids',
     415            'meta_query' => array(
     416                array(
     417                    'key' => 'foo'
     418                ),
     419                array(
     420                    'key' => 'bar',
     421                    'value' => 'bar_val_1'
     422                ),
     423                array(
     424                    'key' => 'baz'
     425                ),
     426                array(
     427                    'key' => 'froo'
     428                ),
     429                'relation' => 'OR',
     430            ),
     431        ) );
     432
     433        $expected = array( $post_id, $post_id2, $post_id3, $post_id4 );
     434        $this->assertEqualSets( $expected, $query->posts );
     435    }
     436
     437    public function test_meta_query_relation_and() {
     438        $post_id = self::factory()->post->create();
     439        add_post_meta( $post_id, 'foo', 'foo_val_1' );
     440        add_post_meta( $post_id, 'foo', 'foo_val_2' );
     441
     442        $post_id2 = self::factory()->post->create();
     443        add_post_meta( $post_id2, 'bar', 'val_2' );
     444        add_post_meta( $post_id2, 'foo', 'foo_val_3' );
     445
     446        $post_id3 = self::factory()->post->create();
     447        add_post_meta( $post_id3, 'baz', 'baz_val_1' );
     448
     449        $post_id4 = self::factory()->post->create();
     450        add_post_meta( $post_id4, 'froo', 'froo_val_1' );
     451
     452        $post_id5 = self::factory()->post->create();
     453        add_post_meta( $post_id5, 'tango', 'val_2' );
     454
    403455        $post_id6 = self::factory()->post->create();
    404456        add_post_meta( $post_id6, 'bar', 'val1' );
    405 
    406         $query = new WP_Query( array(
    407             'update_post_meta_cache' => false,
    408             'update_post_term_cache' => false,
    409             'fields' => 'ids',
     457        add_post_meta( $post_id6, 'foo', 'foo_val_4' );
     458
     459        $post_id7 = self::factory()->post->create();
     460        add_post_meta( $post_id7, 'foo', 'foo_val_5' );
     461        add_post_meta( $post_id7, 'froo', 'froo_val_2' );
     462        add_post_meta( $post_id7, 'baz', 'baz_val_2' );
     463        add_post_meta( $post_id7, 'bar', 'val_2' );
     464
     465        $query = new WP_Query( array(
    410466            'meta_query' => array(
    411467                array(
     
    414470                array(
    415471                    'key' => 'bar',
    416                     'value' => 'val2'
    417                 ),
    418                 array(
    419                     'key' => 'baz'
    420                 ),
    421                 array(
    422                     'key' => 'froo'
    423                 ),
    424                 'relation' => 'OR',
    425             ),
    426         ) );
    427 
    428         $expected = array( $post_id, $post_id2, $post_id3, $post_id4 );
    429         $this->assertEqualSets( $expected, $query->posts );
    430     }
    431 
    432     public function test_meta_query_relation_and() {
    433         $post_id = self::factory()->post->create();
    434         add_post_meta( $post_id, 'foo', rand_str() );
    435         add_post_meta( $post_id, 'foo', rand_str() );
    436         $post_id2 = self::factory()->post->create();
    437         add_post_meta( $post_id2, 'bar', 'val2' );
    438         add_post_meta( $post_id2, 'foo', rand_str() );
    439         $post_id3 = self::factory()->post->create();
    440         add_post_meta( $post_id3, 'baz', rand_str() );
    441         $post_id4 = self::factory()->post->create();
    442         add_post_meta( $post_id4, 'froo', rand_str() );
    443         $post_id5 = self::factory()->post->create();
    444         add_post_meta( $post_id5, 'tango', 'val2' );
    445         $post_id6 = self::factory()->post->create();
    446         add_post_meta( $post_id6, 'bar', 'val1' );
    447         add_post_meta( $post_id6, 'foo', rand_str() );
    448         $post_id7 = self::factory()->post->create();
    449         add_post_meta( $post_id7, 'foo', rand_str() );
    450         add_post_meta( $post_id7, 'froo', rand_str() );
    451         add_post_meta( $post_id7, 'baz', rand_str() );
    452         add_post_meta( $post_id7, 'bar', 'val2' );
    453 
    454         $query = new WP_Query( array(
    455             'meta_query' => array(
    456                 array(
    457                     'key' => 'foo'
    458                 ),
    459                 array(
    460                     'key' => 'bar',
    461                     'value' => 'val2'
     472                    'value' => 'val_2'
    462473                ),
    463474                array(
     
    566577    public function test_meta_query_compare_not_exists() {
    567578        $post_id = self::factory()->post->create();
    568         add_post_meta( $post_id, 'foo', rand_str() );
     579        add_post_meta( $post_id, 'foo', 'foo_val_1' );
     580
    569581        $post_id2 = self::factory()->post->create();
    570         add_post_meta( $post_id2, 'bar', rand_str() );
     582        add_post_meta( $post_id2, 'bar', 'bar_val_1' );
     583
    571584        $post_id3 = self::factory()->post->create();
    572         add_post_meta( $post_id3, 'bar', rand_str() );
     585        add_post_meta( $post_id3, 'bar', 'bar_val_2' );
     586
    573587        $post_id4 = self::factory()->post->create();
    574         add_post_meta( $post_id4, 'baz', rand_str() );
     588        add_post_meta( $post_id4, 'baz', 'baz_val_1' );
     589
    575590        $post_id5 = self::factory()->post->create();
    576         add_post_meta( $post_id5, 'foo', rand_str() );
     591        add_post_meta( $post_id5, 'foo', 'foo_val_2' );
    577592
    578593        $query = new WP_Query( array(
     
    14531468        add_post_meta( $post_id4, 'baz', 'bar' );
    14541469        $post_id5 = self::factory()->post->create();
    1455         add_post_meta( $post_id5, 'foo', rand_str() );
     1470        add_post_meta( $post_id5, 'foo', 'tango' );
    14561471
    14571472        $posts = get_posts( array(
  • trunk/tests/phpunit/tests/user/capabilities.php

    r38861 r38938  
    675675
    676676        global $wp_roles;
    677         $role_name = rand_str();
     677        $role_name = 'janitor';
    678678        add_role( $role_name, 'Janitor', array('level_1'=>true) );
    679679        $this->_flush_roles();
     
    715715
    716716        global $wp_roles;
    717         $role_name = rand_str();
     717        $role_name = 'janitor';
    718718        add_role( $role_name, 'Janitor', array('level_1'=>true, 'sweep_floor'=>true, 'polish_doorknobs'=>true) );
    719719        $this->_flush_roles();
  • trunk/tests/phpunit/tests/user/wpDeleteUser.php

    r37954 r38938  
    6161            'post_author' => $user_id,
    6262            'post_status' => 'publish',
    63             'post_content' => rand_str(),
    64             'post_title' => rand_str(),
     63            'post_content' => 'Post content',
     64            'post_title' => 'Post Title',
    6565            'post_type' => 'post',
    6666        );
     
    7777            'post_author' => $user_id,
    7878            'post_status' => 'publish',
    79             'post_content' => rand_str(),
    80             'post_title' => rand_str(),
     79            'post_content' => 'Post content',
     80            'post_title' => 'Post Title',
    8181            'post_type' => 'nav_menu_item',
    8282        );
  • trunk/tests/phpunit/tests/xmlrpc/wp/editComment.php

    r37914 r38938  
    5757            'comment_author_url' => 'http://example.com/',
    5858            'comment_author_email' => 'example@example.com',
    59             'comment_content' => rand_str( 100 ),
     59            'comment_content' => 'Comment content',
    6060            'comment_approved' => '1'
    6161        );
  • trunk/tests/phpunit/tests/xmlrpc/wp/editProfile.php

    r25002 r38938  
    4242    function test_ignore_password_change() {
    4343        $this->make_user_by_role( 'author' );
    44         $new_pass = rand_str();
     44        $new_pass = 'newpassword';
    4545        $new_data = array( 'password' => $new_pass );
    4646
     
    5757    function test_ignore_email_change() {
    5858        $editor_id = $this->make_user_by_role( 'editor' );
    59         $new_email = rand_str() . '@example.com';
     59        $new_email = 'notaneditor@example.com';
    6060        $new_data = array( 'email' => $new_email );
    6161
  • trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php

    r38382 r38938  
    4343
    4444        // make sure there's at least one category
    45         $cat = wp_insert_term( 'term' . rand_str() , 'category' );
     45        $cat = wp_insert_term( 'term_' . __FUNCTION__ , 'category' );
    4646
    4747        $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) );
     
    104104        $this->make_user_by_role( 'editor' );
    105105
    106         $cat1 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
    107         $cat2 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
     106        $cat1 = wp_create_category( 'wp.getTerms_' . __FUNCTION__ . '_1' );
     107        $cat2 = wp_create_category( 'wp.getTerms_' . __FUNCTION__ . '_2' );
    108108
    109109        self::factory()->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) );
     
    128128        $this->make_user_by_role( 'editor' );
    129129
    130         $name = rand_str( 30 );
     130        $name = __FUNCTION__;
    131131        $name_id = wp_create_category( $name );
    132132
  • trunk/tests/phpunit/tests/xmlrpc/wp/getUser.php

    r35244 r38938  
    5757        $user_data = array(
    5858            'user_login' => 'getusertestuser',
    59             'user_pass' => rand_str(),
    60             'first_name' => rand_str(),
    61             'last_name' => rand_str(),
    62             'description' => rand_str( 100 ),
     59            'user_pass' => 'password',
     60            'first_name' => 'First',
     61            'last_name' => 'Last',
     62            'description' => 'I love WordPress',
    6363            'user_email' => 'getUserTestUser@example.com',
    64             'nickname' => rand_str(),
    65             'user_nicename' => rand_str(),
    66             'display_name' => rand_str(),
     64            'nickname' => 'nickname',
     65            'user_nicename' => 'nicename',
     66            'display_name' => 'First Last',
    6767            'user_url' => 'http://www.example.com/testuser',
    6868            'role' => 'author',
    69             'aim' => rand_str(),
     69            'aim' => 'wordpress',
    7070            'user_registered' => strftime( "%Y-%m-%d %H:%M:%S", $registered_date )
    7171        );
  • trunk/tests/phpunit/tests/xmlrpc/wp/getUsers.php

    r35242 r38938  
    4848            grant_super_admin( $administrator_id );
    4949
    50         $filter = array( 'role' => rand_str() );
     50        $filter = array( 'role' => 'invalidrole' );
    5151        $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
    5252        $this->assertInstanceOf( 'IXR_Error', $results );
Note: See TracChangeset for help on using the changeset viewer.