Make WordPress Core


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

Build/Test Tools: Begin eliminating unnecessary randomness in tests.

Although unlikely, clashes in randomly generated strings could cause unexpected failures. In addition, most randomness is entirely unnecessary, is bad practice, and increases test time (however small it may be).

See #37371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/hooks/do_action.php

    r38571 r38762  
    2020        $callback = array( $a, 'action' );
    2121        $hook = new WP_Hook();
    22         $tag = rand_str();
     22        $tag = __FUNCTION__;
    2323        $priority = rand( 1, 100 );
    2424        $accepted_args = rand( 1, 100 );
    25         $arg = rand_str();
     25        $arg = __FUNCTION__ . '_arg';
    2626
    2727        $hook->add_filter( $tag, $callback, $priority, $accepted_args );
     
    3535        $callback = array( $a, 'filter' );
    3636        $hook = new WP_Hook();
    37         $tag = rand_str();
     37        $tag = __FUNCTION__;
    3838        $priority = rand( 1, 100 );
    3939        $accepted_args = rand( 1, 100 );
    40         $arg = rand_str();
     40        $arg = __FUNCTION__ . '_arg';
    4141
    4242        $hook->add_filter( $tag, $callback, $priority, $accepted_args );
     
    5353        $callback_two = array( $b, 'filter' );
    5454        $hook = new WP_Hook();
    55         $tag = rand_str();
     55        $tag = __FUNCTION__;
    5656        $priority = rand( 1, 100 );
    5757        $accepted_args = rand( 1, 100 );
    58         $arg = rand_str();
     58        $arg = __FUNCTION__ . '_arg';
    5959
    6060        $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
     
    7272        $callback_two = array( $b, 'filter' );
    7373        $hook = new WP_Hook();
    74         $tag = rand_str();
     74        $tag = __FUNCTION__;
    7575        $priority = rand( 1, 100 );
    7676        $accepted_args = rand( 1, 100 );
    77         $arg = rand_str();
     77        $arg = __FUNCTION__ . '_arg';
    7878
    7979        $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
     
    8888        $callback = array( $this, '_action_callback' );
    8989        $hook = new WP_Hook();
    90         $tag = rand_str();
     90        $tag = __FUNCTION__;
    9191        $priority = rand( 1, 100 );
    9292        $accepted_args = 0;
    93         $arg = rand_str();
     93        $arg = __FUNCTION__ . '_arg';
    9494
    9595        $hook->add_filter( $tag, $callback, $priority, $accepted_args );
     
    102102        $callback = array( $this, '_action_callback' );
    103103        $hook = new WP_Hook();
    104         $tag = rand_str();
     104        $tag = __FUNCTION__;
    105105        $priority = rand( 1, 100 );
    106106        $accepted_args = 1;
    107         $arg = rand_str();
     107        $arg = __FUNCTION__ . '_arg';
    108108
    109109        $hook->add_filter( $tag, $callback, $priority, $accepted_args );
     
    116116        $callback = array( $this, '_action_callback' );
    117117        $hook = new WP_Hook();
    118         $tag = rand_str();
     118        $tag = __FUNCTION__;
    119119        $priority = rand( 1, 100 );
    120120        $accepted_args = 1000;
    121         $arg = rand_str();
     121        $arg = __FUNCTION__ . '_arg';
    122122
    123123        $hook->add_filter( $tag, $callback, $priority, $accepted_args );
Note: See TracChangeset for help on using the changeset viewer.