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/xmlrpc/wp/editProfile.php

    r40417 r42343  
    1313    }
    1414
    15     function test_subscriber_profile() {
    16         $subscriber_id = $this->make_user_by_role( 'subscriber' );
     15    function test_subscriber_profile() {
     16        $subscriber_id = $this->make_user_by_role( 'subscriber' );
    1717
    18         $new_data = array(
    19             'first_name' => rand_str(),
    20             'last_name' => rand_str(),
    21             'url' => 'http://www.example.org/subscriber',
    22             'display_name' => rand_str(),
    23             'nickname' => rand_str(),
    24             'nicename' => rand_str(),
    25             'bio' => rand_str(200)
    26         );
    27         $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) );
    28         $this->assertNotIXRError( $result );
    29         $this->assertTrue( $result );
     18        $new_data = array(
     19            'first_name'  => rand_str(),
     20            'last_name'    => rand_str(),
     21            'url'          => 'http://www.example.org/subscriber',
     22            'display_name' => rand_str(),
     23            'nickname'    => rand_str(),
     24            'nicename'    => rand_str(),
     25            'bio'          => rand_str( 200 ),
     26        );
     27        $result  = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) );
     28        $this->assertNotIXRError( $result );
     29        $this->assertTrue( $result );
    3030
    31         // verify that the new values were stored
    32         $user_data = get_userdata( $subscriber_id );
    33         $this->assertEquals( $new_data['first_name'], $user_data->first_name );
    34         $this->assertEquals( $new_data['last_name'], $user_data->last_name );
    35         $this->assertEquals( $new_data['url'], $user_data->user_url );
    36         $this->assertEquals( $new_data['display_name'], $user_data->display_name );
    37         $this->assertEquals( $new_data['nickname'], $user_data->nickname );
    38         $this->assertEquals( $new_data['nicename'], $user_data->user_nicename );
    39         $this->assertEquals( $new_data['bio'], $user_data->description );
    40     }
     31        // verify that the new values were stored
     32        $user_data = get_userdata( $subscriber_id );
     33        $this->assertEquals( $new_data['first_name'], $user_data->first_name );
     34        $this->assertEquals( $new_data['last_name'], $user_data->last_name );
     35        $this->assertEquals( $new_data['url'], $user_data->user_url );
     36        $this->assertEquals( $new_data['display_name'], $user_data->display_name );
     37        $this->assertEquals( $new_data['nickname'], $user_data->nickname );
     38        $this->assertEquals( $new_data['nicename'], $user_data->user_nicename );
     39        $this->assertEquals( $new_data['bio'], $user_data->description );
     40    }
    4141
    42     function test_ignore_password_change() {
    43         $this->make_user_by_role( 'author' );
    44         $new_pass = 'newpassword';
    45         $new_data = array( 'password' => $new_pass );
     42    function test_ignore_password_change() {
     43        $this->make_user_by_role( 'author' );
     44        $new_pass = 'newpassword';
     45        $new_data = array( 'password' => $new_pass );
    4646
    47         $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'author', 'author', $new_data ) );
    48         $this->assertNotIXRError( $result );
    49         $this->assertTrue( $result );
     47        $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'author', 'author', $new_data ) );
     48        $this->assertNotIXRError( $result );
     49        $this->assertTrue( $result );
    5050
    51         $auth_old = wp_authenticate( 'author', 'author' );
    52         $auth_new = wp_authenticate( 'author', $new_pass );
    53         $this->assertInstanceOf( 'WP_User', $auth_old );
    54         $this->assertWPError( $auth_new );
    55     }
     51        $auth_old = wp_authenticate( 'author', 'author' );
     52        $auth_new = wp_authenticate( 'author', $new_pass );
     53        $this->assertInstanceOf( 'WP_User', $auth_old );
     54        $this->assertWPError( $auth_new );
     55    }
    5656
    57     function test_ignore_email_change() {
    58         $editor_id = $this->make_user_by_role( 'editor' );
    59         $new_email = 'notaneditor@example.com';
    60         $new_data = array( 'email' => $new_email );
     57    function test_ignore_email_change() {
     58        $editor_id = $this->make_user_by_role( 'editor' );
     59        $new_email = 'notaneditor@example.com';
     60        $new_data = array( 'email' => $new_email );
    6161
    62         $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'editor', 'editor', $new_data ) );
    63         $this->assertNotIXRError( $result );
    64         $this->assertTrue( $result );
     62        $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'editor', 'editor', $new_data ) );
     63        $this->assertNotIXRError( $result );
     64        $this->assertTrue( $result );
    6565
    66         $user_data = get_userdata( $editor_id );
    67         $this->assertNotEquals( $new_email, $user_data->email );
    68     }
     66        $user_data = get_userdata( $editor_id );
     67        $this->assertNotEquals( $new_email, $user_data->email );
     68    }
    6969}
Note: See TracChangeset for help on using the changeset viewer.