Make WordPress Core

Changeset 49004


Ignore:
Timestamp:
09/19/2020 10:53:15 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Give the $id variable in slashed data tests a more descriptive name.

See #50767, #51344.

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/attachment/slashes.php

    r49003 r49004  
    3333         */
    3434        function test_wp_insert_attachment() {
    35                 $id  = wp_insert_attachment(
     35                $post_id = wp_insert_attachment(
    3636                        array(
    3737                                'post_status'           => 'publish',
    … …  
    4242                        )
    4343                );
    44                 $post = get_post( $id );
     44                $post    = get_post( $post_id );
    4545
    4646                $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
    … …  
    4848                $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt );
    4949
    50                 $id  = wp_insert_attachment(
     50                $post_id = wp_insert_attachment(
    5151                        array(
    5252                                'post_status'           => 'publish',
    … …  
    5757                        )
    5858                );
    59                 $post = get_post( $id );
     59                $post    = get_post( $post_id );
    6060
    6161                $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
  • trunk/tests/phpunit/tests/comment/slashes.php

    r49003 r49004  
    3838                // Not testing comment_author_email or comment_author_url
    3939                // as slashes are not permitted in that data.
    40                 $data = array(
     40                $data       = array(
    4141                        'comment_post_ID'      => $post_id,
    4242                        'comment_author'       => $this->slash_1,
    … …  
    4646                        'comment_content'      => $this->slash_7,
    4747                );
    48                 $id  = wp_new_comment( $data );
     48                $comment_id = wp_new_comment( $data );
    4949
    50                 $comment = get_comment( $id );
     50                $comment = get_comment( $comment_id );
    5151
    5252                $this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
    5353                $this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
    5454
    55                 $data = array(
     55                $data       = array(
    5656                        'comment_post_ID'      => $post_id,
    5757                        'comment_author'       => $this->slash_2,
    … …  
    6161                        'comment_content'      => $this->slash_4,
    6262                );
    63                 $id  = wp_new_comment( $data );
     63                $comment_id = wp_new_comment( $data );
    6464
    65                 $comment = get_comment( $id );
     65                $comment = get_comment( $comment_id );
    6666
    6767                $this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
  • trunk/tests/phpunit/tests/meta/slashes.php

    r48937 r49004  
    3535         */
    3636        function test_edit_post() {
    37                 $id = self::factory()->post->create();
     37                $post_id = self::factory()->post->create();
     38
    3839                if ( function_exists( 'wp_add_post_meta' ) ) {
    39                         $meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' );
    40                         $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' );
    41                         $meta_3 = wp_add_post_meta( $id, 'slash_test_3', 'foo' );
     40                        $meta_1 = wp_add_post_meta( $post_id, 'slash_test_1', 'foo' );
     41                        $meta_2 = wp_add_post_meta( $post_id, 'slash_test_2', 'foo' );
     42                        $meta_3 = wp_add_post_meta( $post_id, 'slash_test_3', 'foo' );
    4243                } else {
    4344                        // Expects slashed data.
    44                         $meta_1 = add_post_meta( $id, 'slash_test_1', addslashes( 'foo' ) );
    45                         $meta_2 = add_post_meta( $id, 'slash_test_2', addslashes( 'foo' ) );
    46                         $meta_3 = add_post_meta( $id, 'slash_test_3', addslashes( 'foo' ) );
     45                        $meta_1 = add_post_meta( $post_id, 'slash_test_1', addslashes( 'foo' ) );
     46                        $meta_2 = add_post_meta( $post_id, 'slash_test_2', addslashes( 'foo' ) );
     47                        $meta_3 = add_post_meta( $post_id, 'slash_test_3', addslashes( 'foo' ) );
    4748                }
    4849
    4950                $_POST                  = array();
    50                 $_POST['post_ID']       = $id;
     51                $_POST['post_ID']       = $post_id;
    5152                $_POST['metakeyselect'] = '#NONE#';
    5253                $_POST['metakeyinput']  = 'slash_test_0';
    … …  
    7071
    7172                edit_post();
    72                 $post = get_post( $id );
    73 
    74                 $this->assertSame( $this->slash_6, get_post_meta( $id, 'slash_test_0', true ) );
    75                 $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) );
    76                 $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) );
    77                 $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) );
     73                $post = get_post( $post_id );
     74
     75                $this->assertSame( $this->slash_6, get_post_meta( $post_id, 'slash_test_0', true ) );
     76                $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
     77                $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
     78                $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
    7879
    7980                $_POST                  = array();
    80                 $_POST['post_ID']       = $id;
     81                $_POST['post_ID']       = $post_id;
    8182                $_POST['metakeyselect'] = '#NONE#';
    8283                $_POST['metakeyinput']  = 'slash_test_0';
    … …  
    100101
    101102                edit_post();
    102                 $post = get_post( $id );
    103 
    104                 $this->assertSame( $this->slash_2, get_post_meta( $id, 'slash_test_1', true ) );
    105                 $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_2', true ) );
    106                 $this->assertSame( $this->slash_5, get_post_meta( $id, 'slash_test_3', true ) );
     103                $post = get_post( $post_id );
     104
     105                $this->assertSame( $this->slash_2, get_post_meta( $post_id, 'slash_test_1', true ) );
     106                $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_2', true ) );
     107                $this->assertSame( $this->slash_5, get_post_meta( $post_id, 'slash_test_3', true ) );
    107108        }
    108109
    … …  
    111112         */
    112113        function test_add_post_meta() {
    113                 $id = self::factory()->post->create();
    114                 add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
    115                 add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
    116                 add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
    117 
    118                 $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) );
    119                 $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) );
    120                 $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) );
     114                $post_id = self::factory()->post->create();
     115
     116                add_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
     117                add_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) );
     118                add_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) );
     119
     120                $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
     121                $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
     122                $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
    121123        }
    122124
    … …  
    125127         */
    126128        function test_update_post_meta() {
    127                 $id = self::factory()->post->create();
    128                 update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
    129                 update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
    130                 update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
    131 
    132                 $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) );
    133                 $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) );
    134                 $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) );
     129                $post_id = self::factory()->post->create();
     130
     131                update_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
     132                update_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) );
     133                update_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) );
     134
     135                $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
     136                $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
     137                $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
    135138        }
    136139
    … …  
    139142         */
    140143        function test_add_comment_meta() {
    141                 $id = self::$comment_id;
    142 
    143                 add_comment_meta( $id, 'slash_test_1', $this->slash_1 );
    144                 add_comment_meta( $id, 'slash_test_2', $this->slash_3 );
    145                 add_comment_meta( $id, 'slash_test_3', $this->slash_5 );
    146 
    147                 $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) );
    148                 $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) );
    149                 $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) );
    150 
    151                 add_comment_meta( $id, 'slash_test_4', $this->slash_2 );
    152                 add_comment_meta( $id, 'slash_test_5', $this->slash_4 );
    153                 add_comment_meta( $id, 'slash_test_6', $this->slash_6 );
    154 
    155                 $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_4', true ) );
    156                 $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_5', true ) );
    157                 $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_6', true ) );
     144                $comment_id = self::$comment_id;
     145
     146                add_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 );
     147                add_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 );
     148                add_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 );
     149
     150                $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
     151                $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
     152                $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
     153
     154                add_comment_meta( $comment_id, 'slash_test_4', $this->slash_2 );
     155                add_comment_meta( $comment_id, 'slash_test_5', $this->slash_4 );
     156                add_comment_meta( $comment_id, 'slash_test_6', $this->slash_6 );
     157
     158                $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_4', true ) );
     159                $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_5', true ) );
     160                $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_6', true ) );
    158161        }
    159162
    … …  
    162165         */
    163166        function test_update_comment_meta() {
    164                 $id = self::$comment_id;
    165 
    166                 add_comment_meta( $id, 'slash_test_1', 'foo' );
    167                 add_comment_meta( $id, 'slash_test_2', 'foo' );
    168                 add_comment_meta( $id, 'slash_test_3', 'foo' );
    169 
    170                 update_comment_meta( $id, 'slash_test_1', $this->slash_1 );
    171                 update_comment_meta( $id, 'slash_test_2', $this->slash_3 );
    172                 update_comment_meta( $id, 'slash_test_3', $this->slash_5 );
    173 
    174                 $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) );
    175                 $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) );
    176                 $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) );
    177 
    178                 update_comment_meta( $id, 'slash_test_1', $this->slash_2 );
    179                 update_comment_meta( $id, 'slash_test_2', $this->slash_4 );
    180                 update_comment_meta( $id, 'slash_test_3', $this->slash_6 );
    181 
    182                 $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_1', true ) );
    183                 $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_2', true ) );
    184                 $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_3', true ) );
     167                $comment_id = self::$comment_id;
     168
     169                add_comment_meta( $comment_id, 'slash_test_1', 'foo' );
     170                add_comment_meta( $comment_id, 'slash_test_2', 'foo' );
     171                add_comment_meta( $comment_id, 'slash_test_3', 'foo' );
     172
     173                update_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 );
     174                update_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 );
     175                update_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 );
     176
     177                $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
     178                $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
     179                $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
     180
     181                update_comment_meta( $comment_id, 'slash_test_1', $this->slash_2 );
     182                update_comment_meta( $comment_id, 'slash_test_2', $this->slash_4 );
     183                update_comment_meta( $comment_id, 'slash_test_3', $this->slash_6 );
     184
     185                $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
     186                $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
     187                $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
    185188        }
    186189
    … …  
    189192         */
    190193        function test_add_user_meta() {
    191                 $id = self::factory()->user->create();
    192 
    193                 add_user_meta( $id, 'slash_test_1', $this->slash_1 );
    194                 add_user_meta( $id, 'slash_test_2', $this->slash_3 );
    195                 add_user_meta( $id, 'slash_test_3', $this->slash_5 );
    196 
    197                 $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) );
    198                 $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) );
    199                 $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) );
    200 
    201                 add_user_meta( $id, 'slash_test_4', $this->slash_2 );
    202                 add_user_meta( $id, 'slash_test_5', $this->slash_4 );
    203                 add_user_meta( $id, 'slash_test_6', $this->slash_6 );
    204 
    205                 $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_4', true ) );
    206                 $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_5', true ) );
    207                 $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_6', true ) );
     194                $user_id = self::factory()->user->create();
     195
     196                add_user_meta( $user_id, 'slash_test_1', $this->slash_1 );
     197                add_user_meta( $user_id, 'slash_test_2', $this->slash_3 );
     198                add_user_meta( $user_id, 'slash_test_3', $this->slash_5 );
     199
     200                $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
     201                $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
     202                $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
     203
     204                add_user_meta( $user_id, 'slash_test_4', $this->slash_2 );
     205                add_user_meta( $user_id, 'slash_test_5', $this->slash_4 );
     206                add_user_meta( $user_id, 'slash_test_6', $this->slash_6 );
     207
     208                $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_4', true ) );
     209                $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_5', true ) );
     210                $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_6', true ) );
    208211        }
    209212
    … …  
    212215         */
    213216        function test_update_user_meta() {
    214                 $id = self::factory()->user->create();
    215 
    216                 add_user_meta( $id, 'slash_test_1', 'foo' );
    217                 add_user_meta( $id, 'slash_test_2', 'foo' );
    218                 add_user_meta( $id, 'slash_test_3', 'foo' );
    219 
    220                 update_user_meta( $id, 'slash_test_1', $this->slash_1 );
    221                 update_user_meta( $id, 'slash_test_2', $this->slash_3 );
    222                 update_user_meta( $id, 'slash_test_3', $this->slash_5 );
    223 
    224                 $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) );
    225                 $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) );
    226                 $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) );
    227 
    228                 update_user_meta( $id, 'slash_test_1', $this->slash_2 );
    229                 update_user_meta( $id, 'slash_test_2', $this->slash_4 );
    230                 update_user_meta( $id, 'slash_test_3', $this->slash_6 );
    231 
    232                 $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_1', true ) );
    233                 $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_2', true ) );
    234                 $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_3', true ) );
     217                $user_id = self::factory()->user->create();
     218
     219                add_user_meta( $user_id, 'slash_test_1', 'foo' );
     220                add_user_meta( $user_id, 'slash_test_2', 'foo' );
     221                add_user_meta( $user_id, 'slash_test_3', 'foo' );
     222
     223                update_user_meta( $user_id, 'slash_test_1', $this->slash_1 );
     224                update_user_meta( $user_id, 'slash_test_2', $this->slash_3 );
     225                update_user_meta( $user_id, 'slash_test_3', $this->slash_5 );
     226
     227                $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
     228                $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
     229                $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
     230
     231                update_user_meta( $user_id, 'slash_test_1', $this->slash_2 );
     232                update_user_meta( $user_id, 'slash_test_2', $this->slash_4 );
     233                update_user_meta( $user_id, 'slash_test_3', $this->slash_6 );
     234
     235                $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_1', true ) );
     236                $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_2', true ) );
     237                $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_3', true ) );
    235238        }
    236239}
  • trunk/tests/phpunit/tests/post/slashes.php

    r49003 r49004  
    3333         */
    3434        function test_edit_post() {
    35                 $id = self::factory()->post->create();
     35                $post_id = self::factory()->post->create();
    3636
    3737                $_POST               = array();
    38                 $_POST['post_ID']    = $id;
     38                $_POST['post_ID']    = $post_id;
    3939                $_POST['post_title'] = $this->slash_1;
    4040                $_POST['content']    = $this->slash_5;
    … …  
    5151
    5252                $_POST               = array();
    53                 $_POST['post_ID']    = $id;
     53                $_POST['post_ID']    = $post_id;
    5454                $_POST['post_title'] = $this->slash_2;
    5555                $_POST['content']    = $this->slash_4;
    … …  
    7070         */
    7171        function test_wp_insert_post() {
    72                 $id  = wp_insert_post(
     72                $post_id = wp_insert_post(
    7373                        array(
    7474                                'post_status'  => 'publish',
    … …  
    8080                        )
    8181                );
    82                 $post = get_post( $id );
     82                $post    = get_post( $post_id );
    8383
    8484                $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
    … …  
    8686                $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt );
    8787
    88                 $id  = wp_insert_post(
     88                $post_id = wp_insert_post(
    8989                        array(
    9090                                'post_status'  => 'publish',
    … …  
    9595                        )
    9696                );
    97                 $post = get_post( $id );
     97                $post    = get_post( $post_id );
    9898
    9999                $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
    … …  
    106106         */
    107107        function test_wp_update_post() {
    108                 $id = self::factory()->post->create();
     108                $post_id = self::factory()->post->create();
    109109
    110110                wp_update_post(
    111111                        array(
    112                                 'ID'           => $id,
     112                                'ID'           => $post_id,
    113113                                'post_title'   => $this->slash_1,
    114114                                'post_content' => $this->slash_3,
    … …  
    116116                        )
    117117                );
    118                 $post = get_post( $id );
     118                $post = get_post( $post_id );
    119119
    120120                $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
    … …  
    124124                wp_update_post(
    125125                        array(
    126                                 'ID'           => $id,
     126                                'ID'           => $post_id,
    127127                                'post_title'   => $this->slash_2,
    128128                                'post_content' => $this->slash_4,
    … …  
    130130                        )
    131131                );
    132                 $post = get_post( $id );
     132                $post = get_post( $post_id );
    133133
    134134                $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
    … …  
    141141         */
    142142        function test_wp_trash_untrash() {
    143                 $post = array(
     143                $post    = array(
    144144                        'post_title'   => $this->slash_1,
    145145                        'post_content' => $this->slash_3,
    146146                        'post_excerpt' => $this->slash_5,
    147147                );
    148                 $id  = wp_insert_post( wp_slash( $post ) );
     148                $post_id = wp_insert_post( wp_slash( $post ) );
    149149
    150                 $trashed = wp_trash_post( $id );
     150                $trashed = wp_trash_post( $post_id );
    151151                $this->assertNotEmpty( $trashed );
    152152
    153                 $post = get_post( $id );
     153                $post = get_post( $post_id );
    154154
    155155                $this->assertSame( $this->slash_1, $post->post_title );
    … …  
    157157                $this->assertSame( $this->slash_5, $post->post_excerpt );
    158158
    159                 $untrashed = wp_untrash_post( $id );
     159                $untrashed = wp_untrash_post( $post_id );
    160160                $this->assertNotEmpty( $untrashed );
    161161
    162                 $post = get_post( $id );
     162                $post = get_post( $post_id );
    163163
    164164                $this->assertSame( $this->slash_1, $post->post_title );
  • trunk/tests/phpunit/tests/term/slashes.php

    r49003 r49004  
    8383                );
    8484                foreach ( $taxonomies as $taxonomy ) {
    85                         $id = self::factory()->term->create(
     85                        $term_id = self::factory()->term->create(
    8686                                array(
    8787                                        'taxonomy' => $taxonomy,
    … …  
    9090
    9191                        $update = wp_update_term(
    92                                 $id,
     92                                $term_id,
    9393                                $taxonomy,
    9494                                array(
    … …  
    9898                        );
    9999
    100                         $term = get_term( $id, $taxonomy );
     100                        $term = get_term( $term_id, $taxonomy );
    101101                        $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );
    102102                        $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );
    103103
    104104                        $update = wp_update_term(
    105                                 $id,
     105                                $term_id,
    106106                                $taxonomy,
    107107                                array(
    … …  
    110110                                )
    111111                        );
    112                         $term   = get_term( $id, $taxonomy );
     112                        $term   = get_term( $term_id, $taxonomy );
    113113                        $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );
    114114                        $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );
    115115
    116116                        $update = wp_update_term(
    117                                 $id,
     117                                $term_id,
    118118                                $taxonomy,
    119119                                array(
    … …  
    122122                                )
    123123                        );
    124                         $term   = get_term( $id, $taxonomy );
     124                        $term   = get_term( $term_id, $taxonomy );
    125125                        $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );
    126126                        $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );
  • trunk/tests/phpunit/tests/user/slashes.php

    r49003 r49004  
    4949                $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes.
    5050
    51                 $id  = add_user();
    52                 $user = get_user_to_edit( $id );
     51                $user_id = add_user();
     52                $user    = get_user_to_edit( $user_id );
    5353
    5454                $this->assertSame( $this->slash_1, $user->first_name );
    … …  
    7474                $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes.
    7575
    76                 $id  = add_user();
    77                 $user = get_user_to_edit( $id );
     76                $user_id = add_user();
     77                $user    = get_user_to_edit( $user_id );
    7878
    7979                $this->assertSame( $this->slash_2, $user->first_name );
    … …  
    8888         */
    8989        function test_edit_user() {
    90                 $id = self::factory()->user->create();
     90                $user_id = self::factory()->user->create();
    9191
    9292                $_POST                 = array();
    … …  
    103103                $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes.
    104104
    105                 $id   = edit_user( $id );
    106                 $user = get_user_to_edit( $id );
     105                $user_id = edit_user( $user_id );
     106                $user    = get_user_to_edit( $user_id );
    107107
    108108                $this->assertSame( $this->slash_1, $user->first_name );
    … …  
    125125                $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes.
    126126
    127                 $id   = edit_user( $id );
    128                 $user = get_user_to_edit( $id );
     127                $user_id = edit_user( $user_id );
     128                $user    = get_user_to_edit( $user_id );
    129129
    130130                $this->assertSame( $this->slash_2, $user->first_name );
    … …  
    139139         */
    140140        function test_wp_insert_user() {
    141                 $id  = wp_insert_user(
     141                $user_id = wp_insert_user(
    142142                        array(
    143143                                'user_login'   => 'slash_example_user_3',
    … …  
    152152                        )
    153153                );
    154                 $user = get_user_to_edit( $id );
     154                $user    = get_user_to_edit( $user_id );
    155155
    156156                $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name );
    … …  
    160160                $this->assertSame( wp_unslash( $this->slash_3 ), $user->description );
    161161
    162                 $id  = wp_insert_user(
     162                $user_id = wp_insert_user(
    163163                        array(
    164164                                'user_login'   => 'slash_example_user_4',
    … …  
    173173                        )
    174174                );
    175                 $user = get_user_to_edit( $id );
     175                $user    = get_user_to_edit( $user_id );
    176176
    177177                $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name );
    … …  
    186186         */
    187187        function test_wp_update_user() {
    188                 $id  = self::factory()->user->create();
    189                 $id  = wp_update_user(
    190                         array(
    191                                 'ID'           => $id,
     188                $user_id = self::factory()->user->create();
     189                $user_id = wp_update_user(
     190                        array(
     191                                'ID'           => $user_id,
    192192                                'role'         => 'subscriber',
    193193                                'first_name'   => $this->slash_1,
    … …  
    198198                        )
    199199                );
    200                 $user = get_user_to_edit( $id );
     200                $user    = get_user_to_edit( $user_id );
    201201
    202202                $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name );
    … …  
    206206                $this->assertSame( wp_unslash( $this->slash_3 ), $user->description );
    207207
    208                 $id  = wp_update_user(
    209                         array(
    210                                 'ID'           => $id,
     208                $user_id = wp_update_user(
     209                        array(
     210                                'ID'           => $user_id,
    211211                                'role'         => 'subscriber',
    212212                                'first_name'   => $this->slash_2,
    … …  
    217217                        )
    218218                );
    219                 $user = get_user_to_edit( $id );
     219                $user    = get_user_to_edit( $user_id );
    220220
    221221                $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name );
Note: See TracChangeset for help on using the changeset viewer.