Make WordPress Core


Ignore:
Timestamp:
07/02/2019 04:43:01 AM (5 years ago)
Author:
pento
Message:

Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in tests.

See #47632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r42863 r45588  
    120120        // Unauthorized.
    121121        wp_set_current_user( self::$subscriber_user_id );
    122         $nonce          = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
    123         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
    124         $exception      = null;
     122        $nonce             = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
     123        $_POST['nonce']    = $nonce;
     124        $_GET['nonce']     = $nonce;
     125        $_REQUEST['nonce'] = $nonce;
     126        $exception         = null;
    125127        try {
    126128            ob_start();
     
    134136        // Not called setup_theme.
    135137        wp_set_current_user( self::$admin_user_id );
    136         $nonce          = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
    137         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
     138        $nonce             = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
     139        $_POST['nonce']    = $nonce;
     140        $_GET['nonce']     = $nonce;
     141        $_REQUEST['nonce'] = $nonce;
    138142        $this->make_ajax_call( 'customize_save' );
    139143        $this->assertFalse( $this->_last_response_parsed['success'] );
     
    141145
    142146        // Bad nonce.
    143         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = 'bad';
     147        $_POST['nonce']    = 'bad';
     148        $_GET['nonce']     = 'bad';
     149        $_REQUEST['nonce'] = 'bad';
    144150        $wp_customize->setup_theme();
    145151        $this->make_ajax_call( 'customize_save' );
     
    149155        // User cannot create.
    150156        $nonce                            = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
    151         $_POST['nonce']                   = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
     157        $_POST['nonce']                   = $nonce;
     158        $_GET['nonce']                    = $nonce;
     159        $_REQUEST['nonce']                = $nonce;
    152160        $post_type_obj                    = get_post_type_object( 'customize_changeset' );
    153161        $post_type_obj->cap->create_posts = 'create_customize_changesets';
     
    251259        );
    252260        $wp_customize->register_controls();
    253         $nonce          = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
    254         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
     261        $nonce             = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
     262        $_POST['nonce']    = $nonce;
     263        $_GET['nonce']     = $nonce;
     264        $_REQUEST['nonce'] = $nonce;
    255265        $wp_customize->setup_theme();
    256266        return $wp_customize;
     
    483493        $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data']['code'] );
    484494
    485         $nonce          = wp_create_nonce( 'trash_customize_changeset' );
    486         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
     495        $nonce             = wp_create_nonce( 'trash_customize_changeset' );
     496        $_POST['nonce']    = $nonce;
     497        $_GET['nonce']     = $nonce;
     498        $_REQUEST['nonce'] = $nonce;
    487499        $this->make_ajax_call( 'customize_trash' );
    488500        $this->assertFalse( $this->_last_response_parsed['success'] );
     
    568580        $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data'] );
    569581
    570         $nonce          = wp_create_nonce( 'customize_dismiss_autosave_or_lock' );
    571         $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
    572 
    573         $_POST['dismiss_lock'] = $_GET['dismiss_lock'] = $_REQUEST['dismiss_lock'] = true;
     582        $nonce             = wp_create_nonce( 'customize_dismiss_autosave_or_lock' );
     583        $_POST['nonce']    = $nonce;
     584        $_GET['nonce']     = $nonce;
     585        $_REQUEST['nonce'] = $nonce;
     586
     587        $_POST['dismiss_lock']    = true;
     588        $_GET['dismiss_lock']     = true;
     589        $_REQUEST['dismiss_lock'] = true;
    574590        $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
    575591        $this->assertFalse( $this->_last_response_parsed['success'] );
    576592        $this->assertEquals( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] );
    577593
    578         $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = true;
     594        $_POST['dismiss_autosave']    = true;
     595        $_GET['dismiss_autosave']     = true;
     596        $_REQUEST['dismiss_autosave'] = true;
    579597        $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
    580598        $this->assertFalse( $this->_last_response_parsed['success'] );
     
    640658        );
    641659
    642         $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = false;
     660        $_POST['dismiss_autosave']    = false;
     661        $_GET['dismiss_autosave']     = false;
     662        $_REQUEST['dismiss_autosave'] = false;
    643663        $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
    644664        $this->assertTrue( $this->_last_response_parsed['success'] );
    645665        $this->assertEquals( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] );
    646666
    647         $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = true;
     667        $_POST['dismiss_autosave']    = true;
     668        $_GET['dismiss_autosave']     = true;
     669        $_REQUEST['dismiss_autosave'] = true;
    648670        $this->assertNotWPError( $r );
    649671        $this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) );
Note: See TracChangeset for help on using the changeset viewer.