Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r35244 r42343  
    2626        /**
    2727         * Tests the controller function that expects slashed data
    28          *
    2928         */
    3029        function test_edit_post() {
    3130                $id = self::factory()->post->create();
    3231
    33                 $_POST = array();
    34                 $_POST['post_ID'] = $id;
     32                $_POST               = array();
     33                $_POST['post_ID']    = $id;
    3534                $_POST['post_title'] = $this->slash_1;
    36                 $_POST['content'] = $this->slash_5;
    37                 $_POST['excerpt'] = $this->slash_7;
    38                 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
     35                $_POST['content']    = $this->slash_5;
     36                $_POST['excerpt']    = $this->slash_7;
     37                $_POST               = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
    3938
    4039                $post_id = edit_post();
    41                 $post = get_post( $post_id );
     40                $post    = get_post( $post_id );
    4241
    4342                $this->assertEquals( $this->slash_1, $post->post_title );
    … …  
    4544                $this->assertEquals( $this->slash_7, $post->post_excerpt );
    4645
    47                 $_POST = array();
    48                 $_POST['post_ID'] = $id;
     46                $_POST               = array();
     47                $_POST['post_ID']    = $id;
    4948                $_POST['post_title'] = $this->slash_2;
    50                 $_POST['content'] = $this->slash_4;
    51                 $_POST['excerpt'] = $this->slash_6;
    52                 $_POST = add_magic_quotes( $_POST );
     49                $_POST['content']    = $this->slash_4;
     50                $_POST['excerpt']    = $this->slash_6;
     51                $_POST               = add_magic_quotes( $_POST );
    5352
    5453                $post_id = edit_post();
    55                 $post = get_post( $post_id );
     54                $post    = get_post( $post_id );
    5655
    5756                $this->assertEquals( $this->slash_2, $post->post_title );
    … …  
    6261        /**
    6362         * Tests the model function that expects slashed data
    64          *
    6563         */
    6664        function test_wp_insert_post() {
    67                 $id = wp_insert_post(array(
    68                         'post_status' => 'publish',
    69                         'post_title' => $this->slash_1,
    70                         'post_content' => $this->slash_3,
    71                         'post_excerpt' => $this->slash_5,
    72                         'post_type' => 'post',
    73                         'slashed' => false,
    74                 ));
     65                $id   = wp_insert_post(
     66                        array(
     67                                'post_status'  => 'publish',
     68                                'post_title'   => $this->slash_1,
     69                                'post_content' => $this->slash_3,
     70                                'post_excerpt' => $this->slash_5,
     71                                'post_type'    => 'post',
     72                                'slashed'      => false,
     73                        )
     74                );
    7575                $post = get_post( $id );
    7676
    … …  
    7979                $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt );
    8080
    81                 $id = wp_insert_post(array(
    82                         'post_status' => 'publish',
    83                         'post_title' => $this->slash_2,
    84                         'post_content' => $this->slash_4,
    85                         'post_excerpt' => $this->slash_6,
    86                         'post_type' => 'post'
    87                 ));
     81                $id   = wp_insert_post(
     82                        array(
     83                                'post_status'  => 'publish',
     84                                'post_title'   => $this->slash_2,
     85                                'post_content' => $this->slash_4,
     86                                'post_excerpt' => $this->slash_6,
     87                                'post_type'    => 'post',
     88                        )
     89                );
    8890                $post = get_post( $id );
    8991
    … …  
    9597        /**
    9698         * Tests the model function that expects slashed data
    97          *
    9899         */
    99100        function test_wp_update_post() {
    100101                $id = self::factory()->post->create();
    101102
    102                 wp_update_post(array(
    103                         'ID' => $id,
    104                         'post_title' => $this->slash_1,
    105                         'post_content' => $this->slash_3,
    106                         'post_excerpt' => $this->slash_5,
    107                 ));
     103                wp_update_post(
     104                        array(
     105                                'ID'           => $id,
     106                                'post_title'   => $this->slash_1,
     107                                'post_content' => $this->slash_3,
     108                                'post_excerpt' => $this->slash_5,
     109                        )
     110                );
    108111                $post = get_post( $id );
    109112
    … …  
    112115                $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt );
    113116
    114                 wp_update_post(array(
    115                         'ID' => $id,
    116                         'post_title' => $this->slash_2,
    117                         'post_content' => $this->slash_4,
    118                         'post_excerpt' => $this->slash_6,
    119                 ));
     117                wp_update_post(
     118                        array(
     119                                'ID'           => $id,
     120                                'post_title'   => $this->slash_2,
     121                                'post_content' => $this->slash_4,
     122                                'post_excerpt' => $this->slash_6,
     123                        )
     124                );
    120125                $post = get_post( $id );
    121126
    … …  
    134139                        'post_excerpt' => $this->slash_5,
    135140                );
    136                 $id = wp_insert_post( wp_slash( $post ) );
     141                $id   = wp_insert_post( wp_slash( $post ) );
    137142
    138143                $trashed = wp_trash_post( $id );
Note: See TracChangeset for help on using the changeset viewer.