Make WordPress Core


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

    r40417 r42343  
    77
    88    function test_invalid_username_password() {
    9         $post = array();
     9        $post   = array();
    1010        $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) );
    1111        $this->assertIXRError( $result );
     
    1515    function test_edit_own_post() {
    1616        $contributor_id = $this->make_user_by_role( 'contributor' );
    17         $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
    18         $post_id = wp_insert_post( $post );
     17        $post           = array(
     18            'post_title'  => 'Post test',
     19            'post_author' => $contributor_id,
     20        );
     21        $post_id        = wp_insert_post( $post );
    1922
    2023        $new_title = 'Post test (updated)';
    21         $post2 = array( 'title' => $new_title );
    22         $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    23         $this->assertNotIXRError( $result );
    24         $this->assertTrue($result);
     24        $post2     = array( 'title' => $new_title );
     25        $result    = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
     26        $this->assertNotIXRError( $result );
     27        $this->assertTrue( $result );
    2528
    2629        $out = get_post( $post_id );
     
    3235        $contributor_id = $this->make_user_by_role( 'contributor' );
    3336
    34         $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
     37        $post    = array(
     38            'post_title'  => 'Post test',
     39            'post_author' => $contributor_id,
     40        );
    3541        $post_id = wp_insert_post( $post );
    3642
    3743        $new_title = 'Post test (updated)';
    38         $post2 = array( 'title' => $new_title );
    39         $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    40         $this->assertNotIXRError( $result );
    41         $this->assertTrue($result);
     44        $post2     = array( 'title' => $new_title );
     45        $result    = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
     46        $this->assertNotIXRError( $result );
     47        $this->assertTrue( $result );
    4248
    4349        $out = get_post( $post_id );
     
    5056
    5157        $original_title = 'Post test';
    52         $post = array( 'post_title' => $original_title, 'post_author' => $author_id );
    53         $post_id = wp_insert_post( $post );
     58        $post           = array(
     59            'post_title'  => $original_title,
     60            'post_author' => $author_id,
     61        );
     62        $post_id        = wp_insert_post( $post );
    5463
    5564        $new_title = 'Post test (updated)';
    56         $post2 = array( 'title' => $new_title );
    57         $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
     65        $post2     = array( 'title' => $new_title );
     66        $result    = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    5867        $this->assertIXRError( $result );
    5968        $this->assertEquals( 401, $result->code );
     
    6574    function test_capable_reassign_author() {
    6675        $contributor_id = $this->make_user_by_role( 'contributor' );
    67         $author_id = $this->make_user_by_role( 'author' );
     76        $author_id      = $this->make_user_by_role( 'author' );
    6877        $this->make_user_by_role( 'editor' );
    6978
    70         $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
    71         $post_id = wp_insert_post( $post );
    72 
    73         $post2 = array( 'wp_author_id' => $author_id );
     79        $post    = array(
     80            'post_title'  => 'Post test',
     81            'post_author' => $contributor_id,
     82        );
     83        $post_id = wp_insert_post( $post );
     84
     85        $post2  = array( 'wp_author_id' => $author_id );
    7486        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    7587        $this->assertNotIXRError( $result );
    76         $this->assertTrue($result);
     88        $this->assertTrue( $result );
    7789
    7890        $out = get_post( $post_id );
     
    8294    function test_incapable_reassign_author() {
    8395        $contributor_id = $this->make_user_by_role( 'contributor' );
    84         $author_id = $this->make_user_by_role( 'author' );
    85 
    86         $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
    87         $post_id = wp_insert_post( $post );
    88 
    89         $post2 = array( 'wp_author_id' => $author_id );
     96        $author_id      = $this->make_user_by_role( 'author' );
     97
     98        $post    = array(
     99            'post_title'  => 'Post test',
     100            'post_author' => $contributor_id,
     101        );
     102        $post_id = wp_insert_post( $post );
     103
     104        $post2  = array( 'wp_author_id' => $author_id );
    90105        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    91106        $this->assertIXRError( $result );
     
    101116    function test_capable_reassign_author_to_self() {
    102117        $contributor_id = $this->make_user_by_role( 'contributor' );
    103         $editor_id = $this->make_user_by_role( 'editor' );
    104 
    105         $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
    106         $post_id = wp_insert_post( $post );
    107 
    108         $post2 = array( 'wp_author_id' => $editor_id );
     118        $editor_id      = $this->make_user_by_role( 'editor' );
     119
     120        $post    = array(
     121            'post_title'  => 'Post test',
     122            'post_author' => $contributor_id,
     123        );
     124        $post_id = wp_insert_post( $post );
     125
     126        $post2  = array( 'wp_author_id' => $editor_id );
    109127        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    110128        $this->assertNotIXRError( $result );
    111         $this->assertTrue($result);
     129        $this->assertTrue( $result );
    112130
    113131        $out = get_post( $post_id );
     
    120138        $author_id = $this->make_user_by_role( 'author' );
    121139
    122         $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id );
     140        $post    = array(
     141            'post_title'  => 'Post Thumbnail Test',
     142            'post_author' => $author_id,
     143        );
    123144        $post_id = wp_insert_post( $post );
    124145
     
    126147
    127148        // create attachment
    128         $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
     149        $filename      = ( DIR_TESTDATA . '/images/a2-small.jpg' );
    129150        $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    130151
    131152        // add post thumbnail to post that does not have one
    132         $post2 = array( 'wp_post_thumbnail' => $attachment_id );
     153        $post2  = array( 'wp_post_thumbnail' => $attachment_id );
    133154        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) );
    134155        $this->assertNotIXRError( $result );
     
    136157
    137158        // edit the post without supplying a post_thumbnail and check that it didn't change
    138         $post3 = array( 'post_content' => 'Updated post' );
     159        $post3  = array( 'post_content' => 'Updated post' );
    139160        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) );
    140161        $this->assertNotIXRError( $result );
     
    145166
    146167        // change the post's post_thumbnail
    147         $post4 = array( 'wp_post_thumbnail' => $attachment2_id );
     168        $post4  = array( 'wp_post_thumbnail' => $attachment2_id );
    148169        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) );
    149170        $this->assertNotIXRError( $result );
     
    151172
    152173        // unset the post's post_thumbnail
    153         $post5 = array( 'wp_post_thumbnail' => '' );
    154         $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) );
     174        $post5  = array( 'wp_post_thumbnail' => '' );
     175        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post5 ) );
    155176        $this->assertNotIXRError( $result );
    156177        $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
     
    162183        $contributor_id = $this->make_user_by_role( 'contributor' );
    163184
    164         $post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_excerpt' => 'Excerpt', 'post_author' => $contributor_id );
    165         $post_id = wp_insert_post( $post );
    166 
    167         $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id );
     185        $post    = array(
     186            'post_title'   => 'Title',
     187            'post_content' => 'Content',
     188            'post_excerpt' => 'Excerpt',
     189            'post_author'  => $contributor_id,
     190        );
     191        $post_id = wp_insert_post( $post );
     192
     193        $post2  = array(
     194            'title'       => 'New Title',
     195            'post_author' => $contributor_id,
     196        );
    168197        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    169198        $this->assertNotIXRError( $result );
    170         $this->assertTrue($result);
     199        $this->assertTrue( $result );
    171200
    172201        $out = get_post( $post_id );
    173202        $this->assertEquals( $post2['title'], $out->post_title );
    174203
    175         $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id );
     204        $post3  = array(
     205            'description' => 'New Content',
     206            'post_author' => $contributor_id,
     207        );
    176208        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) );
    177209        $this->assertNotIXRError( $result );
    178         $this->assertTrue($result);
     210        $this->assertTrue( $result );
    179211
    180212        $out = get_post( $post_id );
     
    182214        $this->assertEquals( $post3['description'], $out->post_content );
    183215
    184         $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id );
     216        $post4  = array(
     217            'mt_excerpt'  => 'New Excerpt',
     218            'post_author' => $contributor_id,
     219        );
    185220        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) );
    186221        $this->assertNotIXRError( $result );
    187         $this->assertTrue($result);
     222        $this->assertTrue( $result );
    188223
    189224        $out = get_post( $post_id );
     
    199234        $author_id = $this->make_user_by_role( 'editor' );
    200235
    201         $post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_author' => $author_id, 'post_status' => 'publish' );
     236        $post    = array(
     237            'post_title'   => 'Title',
     238            'post_content' => 'Content',
     239            'post_author'  => $author_id,
     240            'post_status'  => 'publish',
     241        );
    202242        $post_id = wp_insert_post( $post );
    203243
     
    211251        $contributor_id = $this->make_user_by_role( 'contributor' );
    212252
    213         $post = array( 'post_title' => 'Title', 'post_author' => $contributor_id );
    214         $post_id = wp_insert_post( $post );
    215 
    216         $post2 = array( 'post_type' => 'page' );
     253        $post    = array(
     254            'post_title'  => 'Title',
     255            'post_author' => $contributor_id,
     256        );
     257        $post_id = wp_insert_post( $post );
     258
     259        $post2  = array( 'post_type' => 'page' );
    217260        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    218261        $this->assertIXRError( $result );
     
    226269        $editor_id = $this->make_user_by_role( 'editor' );
    227270
    228         $post_id = self::factory()->post->create( array(
    229             'post_title' => 'Title',
    230             'post_author' => $editor_id,
    231             'tags_input' => 'taco'
    232         ) );
     271        $post_id = self::factory()->post->create(
     272            array(
     273                'post_title'  => 'Title',
     274                'post_author' => $editor_id,
     275                'tags_input'  => 'taco',
     276            )
     277        );
    233278
    234279        $tags1 = get_the_tags( $post_id );
    235280        $this->assertNotEmpty( $tags1 );
    236281
    237         $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array(
    238             'mt_keywords' => ''
    239         ) ) );
     282        $this->myxmlrpcserver->mw_editPost(
     283            array(
     284                $post_id,
     285                'editor',
     286                'editor',
     287                array(
     288                    'mt_keywords' => '',
     289                ),
     290            )
     291        );
    240292
    241293        $tags2 = get_the_tags( $post_id );
     
    263315        $future_time = strtotime( '+1 day' );
    264316        $future_date = new IXR_Date( $future_time );
    265         $this->myxmlrpcserver->mw_editPost( array(
    266             $post_id,
    267             'editor',
    268             'editor',
     317        $this->myxmlrpcserver->mw_editPost(
    269318            array(
    270                 'dateCreated' => $future_date,
    271                 'post_status' => 'publish',
    272             ),
    273         ) );
     319                $post_id,
     320                'editor',
     321                'editor',
     322                array(
     323                    'dateCreated' => $future_date,
     324                    'post_status' => 'publish',
     325                ),
     326            )
     327        );
    274328
    275329        $after = get_post( $post_id );
Note: See TracChangeset for help on using the changeset viewer.