Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/meta/slashes.php

    r38398 r42343  
    1212
    1313    public static function wpSetUpBeforeClass( $factory ) {
    14         self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
    15         self::$post_id = $factory->post->create();
     14        self::$editor_id  = $factory->user->create( array( 'role' => 'editor' ) );
     15        self::$post_id    = $factory->post->create();
    1616        self::$comment_id = $factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
    1717    }
     
    3333    /**
    3434     * Tests the controller function that expects slashed data
    35      *
    3635     */
    3736    function test_edit_post() {
     
    4140            $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' );
    4241            $meta_3 = wp_add_post_meta( $id, 'slash_test_3', 'foo' );
    43         }
    44         else {
     42        } else {
    4543            // expects slashed data
    4644            $meta_1 = add_post_meta( $id, 'slash_test_1', addslashes( 'foo' ) );
     
    4947        }
    5048
    51         $_POST = array();
    52         $_POST['post_ID'] = $id;
     49        $_POST                  = array();
     50        $_POST['post_ID']       = $id;
    5351        $_POST['metakeyselect'] = '#NONE#';
    54         $_POST['metakeyinput'] = 'slash_test_0';
    55         $_POST['metavalue'] = $this->slash_6;
    56         $_POST['meta'] = array(
     52        $_POST['metakeyinput']  = 'slash_test_0';
     53        $_POST['metavalue']     = $this->slash_6;
     54        $_POST['meta']          = array(
    5755            $meta_1 => array(
    58                 'key' => 'slash_test_1',
    59                 'value' => $this->slash_1
     56                'key'   => 'slash_test_1',
     57                'value' => $this->slash_1,
    6058            ),
    6159            $meta_2 => array(
    62                 'key' => 'slash_test_2',
    63                 'value' => $this->slash_3
     60                'key'   => 'slash_test_2',
     61                'value' => $this->slash_3,
    6462            ),
    6563            $meta_3 => array(
    66                 'key' => 'slash_test_3',
    67                 'value' => $this->slash_4
     64                'key'   => 'slash_test_3',
     65                'value' => $this->slash_4,
    6866            ),
    6967        );
    70         $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
     68        $_POST                  = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
    7169
    7270        edit_post();
     
    7876        $this->assertEquals( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) );
    7977
    80         $_POST = array();
    81         $_POST['post_ID'] = $id;
     78        $_POST                  = array();
     79        $_POST['post_ID']       = $id;
    8280        $_POST['metakeyselect'] = '#NONE#';
    83         $_POST['metakeyinput'] = 'slash_test_0';
    84         $_POST['metavalue'] = $this->slash_7;
    85         $_POST['meta'] = array(
     81        $_POST['metakeyinput']  = 'slash_test_0';
     82        $_POST['metavalue']     = $this->slash_7;
     83        $_POST['meta']          = array(
    8684            $meta_1 => array(
    87                 'key' => 'slash_test_1',
    88                 'value' => $this->slash_2
     85                'key'   => 'slash_test_1',
     86                'value' => $this->slash_2,
    8987            ),
    9088            $meta_2 => array(
    91                 'key' => 'slash_test_2',
    92                 'value' => $this->slash_4
     89                'key'   => 'slash_test_2',
     90                'value' => $this->slash_4,
    9391            ),
    9492            $meta_3 => array(
    95                 'key' => 'slash_test_3',
    96                 'value' => $this->slash_5
     93                'key'   => 'slash_test_3',
     94                'value' => $this->slash_5,
    9795            ),
    9896        );
    99         $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
     97        $_POST                  = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
    10098
    10199        edit_post();
     
    109107    /**
    110108     * Tests the legacy model function that expects slashed data
    111      *
    112109     */
    113110    function test_add_post_meta() {
     
    124121    /**
    125122     * Tests the legacy model function that expects slashed data
    126      *
    127123     */
    128124    function test_update_post_meta() {
     
    139135    /**
    140136     * Tests the model function that expects slashed data
    141      *
    142137     */
    143138    function test_add_comment_meta() {
     
    163158    /**
    164159     * Tests the model function that expects slashed data
    165      *
    166160     */
    167161    function test_update_comment_meta() {
     
    191185    /**
    192186     * Tests the model function that expects slashed data
    193      *
    194187     */
    195188    function test_add_user_meta() {
     
    215208    /**
    216209     * Tests the model function that expects slashed data
    217      *
    218210     */
    219211    function test_update_user_meta() {
Note: See TracChangeset for help on using the changeset viewer.