Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 );
Note: See TracChangeset for help on using the changeset viewer.