Make WordPress Core

Changeset 38763


Ignore:
Timestamp:
10/09/2016 01:29:04 AM (9 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Continue eliminating randomness in tests.

See [38762]
See #37371

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

Legend:

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

    r38571 r38763  
    1010    function test_simple_action() {
    1111        $a = new MockAction();
    12         $tag = 'test_action';
     12        $tag = __FUNCTION__;
    1313
    1414        add_action($tag, array(&$a, 'action'));
     
    2727    function test_remove_action() {
    2828        $a = new MockAction();
    29         $tag = rand_str();
     29        $tag = __FUNCTION__;
    3030
    3131        add_action($tag, array(&$a, 'action'));
     
    4545
    4646    function test_has_action() {
    47         $tag = rand_str();
    48         $func = rand_str();
     47        $tag = __FUNCTION__;
     48        $func = __FUNCTION__ . '_func';
    4949
    5050        $this->assertFalse( has_action($tag, $func) );
     
    6262        $a1 = new MockAction();
    6363        $a2 = new MockAction();
    64         $tag = rand_str();
     64        $tag = __FUNCTION__;
    6565
    6666        // add both actions to the hook
     
    7777    function test_action_args_1() {
    7878        $a = new MockAction();
    79         $tag = rand_str();
    80         $val = rand_str();
     79        $tag = __FUNCTION__;
     80        $val = __FUNCTION__ . '_val';
    8181
    8282        add_action($tag, array(&$a, 'action'));
     
    9393        $a1 = new MockAction();
    9494        $a2 = new MockAction();
    95         $tag = rand_str();
    96         $val1 = rand_str();
    97         $val2 = rand_str();
     95        $tag = __FUNCTION__;
     96        $val1 = __FUNCTION__ . '_val1';
     97        $val2 = __FUNCTION__ . '_val2';
    9898
    9999        // a1 accepts two arguments, a2 doesn't
     
    126126        $a2 = new MockAction();
    127127        $a3 = new MockAction();
    128         $tag = rand_str();
    129         $val1 = rand_str();
    130         $val2 = rand_str();
     128        $tag = __FUNCTION__;
     129        $val1 = __FUNCTION__ . '_val1';
     130        $val2 = __FUNCTION__ . '_val2';
    131131
    132132        // a1 accepts two arguments, a2 doesn't, a3 accepts two arguments
     
    156156    function test_action_priority() {
    157157        $a = new MockAction();
    158         $tag = rand_str();
     158        $tag = __FUNCTION__;
    159159
    160160        add_action($tag, array(&$a, 'action'), 10);
     
    205205    function test_all_action() {
    206206        $a = new MockAction();
    207         $tag1 = rand_str();
    208         $tag2 = rand_str();
     207        $tag1 = __FUNCTION__ . '_1';
     208        $tag2 = __FUNCTION__ . '_2';
    209209
    210210        // add an 'all' action
     
    229229    function test_remove_all_action() {
    230230        $a = new MockAction();
    231         $tag = rand_str();
     231        $tag = __FUNCTION__;
    232232
    233233        add_action('all', array(&$a, 'action'));
     
    250250        $obj = new stdClass();
    251251        $a = new MockAction();
    252         $tag = rand_str();
     252        $tag = __FUNCTION__;
    253253
    254254        add_action($tag, array(&$a, 'action'));
     
    269269        $a = new MockAction();
    270270
    271         $tag = rand_str();
     271        $tag = __FUNCTION__;
    272272
    273273        add_action($tag, array(&$a, 'action'));
    274274
    275         $context = array( rand_str() => rand_str() );
     275        $context = array( 'key1' => 'val1' );
    276276        do_action($tag, $context);
    277277
     
    279279        $this->assertSame($args[0][0], $context);
    280280
    281         $context2 = array( rand_str() => rand_str(), rand_str() => rand_str() );
     281        $context2 = array( 'key2' => 'val2', 'key3' => 'val3' );
    282282        do_action($tag, $context2);
    283283
     
    301301     */
    302302    function test_action_recursion() {
    303         $tag = rand_str();
     303        $tag = __FUNCTION__;
    304304        $a = new MockAction();
    305305        $b = new MockAction();
     
    328328     */
    329329    function test_action_callback_manipulation_while_running() {
    330         $tag = rand_str();
     330        $tag = __FUNCTION__;
    331331        $a = new MockAction();
    332332        $b = new MockAction();
     
    363363     */
    364364    function test_remove_anonymous_callback() {
    365         $tag = rand_str();
     365        $tag = __FUNCTION__;
    366366        $a = new MockAction();
    367367        add_action( $tag, array( $a, 'action' ), 12, 1 );
     
    397397    function test_array_access_of_wp_filter_global() {
    398398        global $wp_filter;
    399         $tag = rand_str();
     399        $tag = __FUNCTION__;
    400400
    401401        add_action( $tag, '__return_null', 11, 1 );
  • trunk/tests/phpunit/tests/actions/closures.php

    r25002 r38763  
    1818        $this->assertSame( 10, has_action($tag, $closure) );
    1919
    20         $context = array( rand_str(), rand_str() );
     20        $context = array( 'val1', 'val2' );
    2121        do_action($tag, $context[0], $context[1]);
    2222
  • trunk/tests/phpunit/tests/admin/includesScreen.php

    r38382 r38763  
    155155
    156156    function test_help_tabs() {
    157         $tab = rand_str();
     157        $tab = __FUNCTION__;
    158158        $tab_args = array(
    159159            'id' => $tab,
     
    279279     */
    280280    function test_options() {
    281         $option = rand_str();
     281        $option = __FUNCTION__;
    282282        $option_args = array(
    283283            'label'   => 'Option',
  • trunk/tests/phpunit/tests/cache.php

    r37954 r38763  
    2828
    2929    function test_miss() {
    30         $this->assertEquals(NULL, $this->cache->get(rand_str()));
     30        $this->assertEquals( NULL, $this->cache->get( 'test_miss' ) );
    3131    }
    3232
    3333    function test_add_get() {
    34         $key = rand_str();
    35         $val = rand_str();
     34        $key = __FUNCTION__;
     35        $val = 'val';
    3636
    3737        $this->cache->add($key, $val);
     
    4040
    4141    function test_add_get_0() {
    42         $key = rand_str();
     42        $key = __FUNCTION__;
    4343        $val = 0;
    4444
     
    4949
    5050    function test_add_get_null() {
    51         $key = rand_str();
     51        $key = __FUNCTION__;
    5252        $val = null;
    5353
     
    5858
    5959    function test_add() {
    60         $key = rand_str();
    61         $val1 = rand_str();
    62         $val2 = rand_str();
     60        $key = __FUNCTION__;
     61        $val1 = 'val1';
     62        $val2 = 'val2';
    6363
    6464        // add $key to the cache
     
    7171
    7272    function test_replace() {
    73         $key = rand_str();
    74         $val = rand_str();
    75         $val2 = rand_str();
     73        $key = __FUNCTION__;
     74        $val = 'val1';
     75        $val2 = 'val2';
    7676
    7777        // memcached rejects replace() if the key does not exist
     
    8585
    8686    function test_set() {
    87         $key = rand_str();
    88         $val1 = rand_str();
    89         $val2 = rand_str();
     87        $key = __FUNCTION__;
     88        $val1 = 'val1';
     89        $val2 = 'val2';
    9090
    9191        // memcached accepts set() if the key does not exist
     
    103103            return;
    104104
    105         $key = rand_str();
    106         $val = rand_str();
     105        $key = __FUNCTION__;
     106        $val = 'val';
    107107
    108108        $this->cache->add($key, $val);
     
    116116    // Make sure objects are cloned going to and from the cache
    117117    function test_object_refs() {
    118         $key = rand_str();
     118        $key = __FUNCTION__ . '_1';
    119119        $object_a = new stdClass;
    120120        $object_a->foo = 'alpha';
     
    126126        $this->assertEquals( 'bravo', $object_a->foo );
    127127
    128         $key = rand_str();
     128        $key = __FUNCTION__ . '_2';
    129129        $object_a = new stdClass;
    130130        $object_a->foo = 'alpha';
     
    138138
    139139    function test_incr() {
    140         $key = rand_str();
     140        $key = __FUNCTION__;
    141141
    142142        $this->assertFalse( $this->cache->incr( $key ) );
     
    151151
    152152    function test_wp_cache_incr() {
    153         $key = rand_str();
     153        $key = __FUNCTION__;
    154154
    155155        $this->assertFalse( wp_cache_incr( $key ) );
     
    164164
    165165    function test_decr() {
    166         $key = rand_str();
     166        $key = __FUNCTION__;
    167167
    168168        $this->assertFalse( $this->cache->decr( $key ) );
     
    184184     */
    185185    function test_wp_cache_decr() {
    186         $key = rand_str();
     186        $key = __FUNCTION__;
    187187
    188188        $this->assertFalse( wp_cache_decr( $key ) );
     
    201201
    202202    function test_delete() {
    203         $key = rand_str();
    204         $val = rand_str();
     203        $key = __FUNCTION__;
     204        $val = 'val';
    205205
    206206        // Verify set
     
    216216
    217217    function test_wp_cache_delete() {
    218         $key = rand_str();
    219         $val = rand_str();
     218        $key = __FUNCTION__;
     219        $val = 'val';
    220220
    221221        // Verify set
     
    238238            return;
    239239
    240         $key = rand_str();
    241         $val = rand_str();
    242         $val2 = rand_str();
     240        $key = __FUNCTION__;
     241        $val = 'val1';
     242        $val2 = 'val2';
    243243
    244244        if ( ! is_multisite() ) {
  • trunk/tests/phpunit/tests/comment-submission.php

    r36272 r38763  
    623623        $data = array(
    624624            'comment_post_ID' => $post->ID,
    625             'comment'         => rand_str(),
     625            'comment'         => 'Comment',
    626626            'author'          => rand_long_str( 255 ),
    627627            'email'           => 'comment@example.org',
     
    643643        $data = array(
    644644            'comment_post_ID' => $post->ID,
    645             'comment'         => rand_str(),
     645            'comment'         => 'Comment',
    646646            'author'          => 'Comment Author',
    647647            'email'           => rand_long_str( 90 ) . '@example.com',
     
    662662        $data = array(
    663663            'comment_post_ID' => $post->ID,
    664             'comment'         => rand_str(),
     664            'comment'         => 'Comment',
    665665            'author'          => 'Comment Author',
    666666            'email'           => 'comment@example.org',
  • trunk/tests/phpunit/tests/comment.php

    r38398 r38763  
    128128        $data = array(
    129129            'comment_post_ID' => self::$post_id,
    130             'comment_author' => rand_str(),
     130            'comment_author' => 'Comment Author',
    131131            'comment_author_url' => '',
    132132            'comment_author_email' => '',
    133133            'comment_type' => '',
    134             'comment_content' => rand_str(),
     134            'comment_content' => 'Comment',
    135135            'comment_date' => '2011-01-01 10:00:00',
    136136            'comment_date_gmt' => '2011-01-01 10:00:00',
     
    151151        $data = array(
    152152            'comment_post_ID'      => self::$post_id,
    153             'comment_author'       => rand_str(),
     153            'comment_author'       => 'Comment Author',
    154154            'comment_author_IP'    => '192.168.1.1',
    155155            'comment_author_url'   => '',
    156156            'comment_author_email' => '',
    157157            'comment_type'         => '',
    158             'comment_content'      => rand_str(),
     158            'comment_content'      => 'Comment',
    159159        );
    160160
     
    172172        $data = array(
    173173            'comment_post_ID'      => self::$post_id,
    174             'comment_author'       => rand_str(),
     174            'comment_author'       => 'Comment Author',
    175175            'comment_author_IP'    => '',
    176176            'comment_author_url'   => '',
    177177            'comment_author_email' => '',
    178178            'comment_type'         => '',
    179             'comment_content'      => rand_str(),
     179            'comment_content'      => 'Comment',
    180180        );
    181181
     
    193193        $data = array(
    194194            'comment_post_ID'      => self::$post_id,
    195             'comment_author'       => rand_str(),
     195            'comment_author'       => 'Comment Author',
    196196            'comment_author_IP'    => '',
    197197            'comment_author_url'   => '',
     
    199199            'comment_agent'        => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53',
    200200            'comment_type'         => '',
    201             'comment_content'      => rand_str(),
     201            'comment_content'      => 'Comment',
    202202        );
    203203
     
    215215        $data = array(
    216216            'comment_post_ID'      => self::$post_id,
    217             'comment_author'       => rand_str(),
     217            'comment_author'       => 'Comment Author',
    218218            'comment_author_IP'    => '',
    219219            'comment_author_url'   => '',
     
    221221            'comment_agent'        => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4pre) Gecko/20070511 Camino/1.6pre',
    222222            'comment_type'         => '',
    223             'comment_content'      => rand_str(),
     223            'comment_content'      => 'Comment',
    224224        );
    225225
     
    237237        $data = array(
    238238            'comment_post_ID'      => self::$post_id,
    239             'comment_author'       => rand_str(),
     239            'comment_author'       => 'Comment Author',
    240240            'comment_author_IP'    => '',
    241241            'comment_author_url'   => '',
     
    243243            'comment_agent'        => '',
    244244            'comment_type'         => '',
    245             'comment_content'      => rand_str(),
     245            'comment_content'      => 'Comment',
    246246        );
    247247
     
    257257        $data = array(
    258258            'comment_post_ID' => self::$post_id,
    259             'comment_author' => rand_str(),
     259            'comment_author' => 'Comment Author',
    260260            'comment_author_url' => '',
    261261            'comment_author_email' => '',
     
    539539        $data = array(
    540540            'comment_post_ID'      => $post,
    541             'comment_author'       => rand_str(),
     541            'comment_author'       => 'Comment Author',
    542542            'comment_author_url'   => '',
    543543            'comment_author_email' => '',
    544544            'comment_type'         => '',
    545             'comment_content'      => rand_str(),
     545            'comment_content'      => 'Comment',
    546546        );
    547547        wp_new_comment( $data );
     
    589589        $data = array(
    590590            'comment_post_ID'      => $post,
    591             'comment_author'       => rand_str(),
     591            'comment_author'       => 'Comment Author',
    592592            'comment_author_url'   => '',
    593593            'comment_author_email' => '',
    594594            'comment_type'         => '',
    595             'comment_content'      => rand_str(),
     595            'comment_content'      => 'Comment',
    596596        );
    597597        wp_new_comment( $data );
     
    639639        $default_data = array(
    640640            'comment_post_ID'      => self::$post_id,
    641             'comment_author'       => rand_str(),
     641            'comment_author'       => 'Comment Author',
    642642            'comment_author_IP'    => '192.168.0.1',
    643643            'comment_agent'        => 'WRONG_AGENT',
     
    645645            'comment_author_email' => '',
    646646            'comment_type'         => '',
    647             'comment_content'      => rand_str(),
     647            'comment_content'      => 'Comment',
    648648        );
    649649
  • trunk/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php

    r38398 r38763  
    4141        unset( $GLOBALS['comment'] );
    4242
    43         $linktext = rand_str( 10 );
    44         $before   = rand_str( 5 );
    45         $after    = rand_str( 6 );
     43        $linktext = 'linktext';
     44        $before   = 'before';
     45        $after    = 'after';
    4646        $comment  = self::factory()->comment->create_and_get( array(
    4747            'comment_author_email' => $email = 'baz@example.org'
     
    5454
    5555    public function test_all_parameters_with_global_comment() {
    56         $linktext = rand_str( 10 );
    57         $before   = rand_str( 5 );
    58         $after    = rand_str( 6 );
     56        $linktext = 'linktext';
     57        $before   = 'before';
     58        $after    = 'after';
    5959
    6060        $expected = sprintf( '%1$s<a href="mailto:foo@example.org">%2$s</a>%3$s', $before, $linktext, $after );
     
    6464
    6565    public function test_linktext() {
    66         $expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = rand_str( 12 ) );
     66        $expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = 'linktext' );
    6767
    6868        $this->assertEquals( $expected, get_comment_author_email_link( $linktext ) );
     
    7070
    7171    public function test_before() {
    72         $expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = rand_str( 5 ) );
     72        $expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = 'before' );
    7373
    7474        $this->assertEquals( $expected, get_comment_author_email_link( '', $before ) );
     
    7676
    7777    public function test_after() {
    78         $expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = rand_str( 5 ) );
     78        $expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = 'after' );
    7979
    8080        $this->assertEquals( $expected, get_comment_author_email_link( '', '', $after ) );
  • trunk/tests/phpunit/tests/cron.php

    r38382 r38763  
    2121    function test_wp_get_schedule_empty() {
    2222        // nothing scheduled
    23         $hook = rand_str();
     23        $hook = __FUNCTION__;
    2424        $this->assertFalse(wp_get_schedule($hook));
    2525    }
     
    2727    function test_schedule_event_single() {
    2828        // schedule an event and make sure it's returned by wp_next_scheduled
    29         $hook = rand_str();
     29        $hook = __FUNCTION__;
    3030        $timestamp = strtotime('+1 hour');
    3131
     
    5757    function test_schedule_event() {
    5858        // schedule an event and make sure it's returned by wp_next_scheduled
    59         $hook = rand_str();
     59        $hook = __FUNCTION__;
    6060        $recur = 'hourly';
    6161        $timestamp = strtotime('+1 hour');
     
    8888    function test_unschedule_event() {
    8989        // schedule an event and make sure it's returned by wp_next_scheduled
    90         $hook = rand_str();
     90        $hook = __FUNCTION__;
    9191        $timestamp = strtotime('+1 hour');
    9292
     
    100100
    101101    function test_clear_schedule() {
    102         $hook = rand_str();
    103         $args = array(rand_str());
     102        $hook = __FUNCTION__;
     103        $args = array( 'arg1' );
    104104
    105105        // schedule several events with and without arguments
     
    126126
    127127    function test_clear_schedule_multiple_args() {
    128         $hook = rand_str();
    129         $args = array(rand_str(), rand_str());
     128        $hook = __FUNCTION__;
     129        $args = array( 'arg1', 'arg2' );
    130130
    131131        // schedule several events with and without arguments
     
    155155     */
    156156    function test_clear_schedule_new_args() {
    157         $hook = rand_str();
    158         $args = array(rand_str());
    159         $multi_hook = rand_str();
    160         $multi_args = array(rand_str(), rand_str());
     157        $hook = __FUNCTION__;
     158        $args = array( 'arg1' );
     159        $multi_hook = __FUNCTION__ . '_multi';
     160        $multi_args = array( 'arg2', 'arg3' );
    161161
    162162        // schedule several events with and without arguments
     
    195195    function test_duplicate_event() {
    196196        // duplicate events close together should be skipped
    197         $hook = rand_str();
    198         $args = array(rand_str());
     197        $hook = __FUNCTION__;
     198        $args = array( 'arg1' );
    199199        $ts1 = strtotime('+5 minutes');
    200200        $ts2 = strtotime('+3 minutes');
     
    214214    function test_not_duplicate_event() {
    215215        // duplicate events far apart should work normally
    216         $hook = rand_str();
    217         $args = array( rand_str() );
     216        $hook = __FUNCTION__;
     217        $args = array( 'arg1' );
    218218        $ts1 = strtotime( '+30 minutes' );
    219219        $ts2 = strtotime( '+3 minutes' );
     
    233233    function test_not_duplicate_event_reversed() {
    234234        // duplicate events far apart should work normally regardless of order
    235         $hook = rand_str();
    236         $args = array( rand_str() );
     235        $hook = __FUNCTION__;
     236        $args = array( 'arg1' );
    237237        $ts1 = strtotime( '+3 minutes' );
    238238        $ts2 = strtotime( '+30 minutes' );
     
    275275    function test_run_schedule_single() {
    276276        // schedule an event, run it, and make sure the hook is called
    277         $hook = rand_str();
     277        $hook = __FUNCTION__;
    278278        $args = array(rand_str());
    279279        $timestamp = strtotime('-1 second');
     
    301301    function test_run_schedule_recurring() {
    302302        // schedule a recurring event, run it, and make sure the hook is called
    303         $hook = rand_str();
     303        $hook = __FUNCTION__;
    304304        $args = array(rand_str());
    305305        $timestamp = strtotime('-1 second');
  • trunk/tests/phpunit/tests/customize/setting.php

    r37982 r38763  
    481481        $type = 'option';
    482482        $name = 'blogname';
    483         $post_value = rand_str();
     483        $post_value = __FUNCTION__;
    484484        $this->manager->set_post_value( $name, $post_value );
    485485        $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
     
    505505        $type = 'option';
    506506        $name = 'blogdescription';
    507         $post_value = rand_str();
     507        $post_value = __FUNCTION__;
    508508        $this->manager->set_post_value( $name, $post_value );
    509509        $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
Note: See TracChangeset for help on using the changeset viewer.