Make WordPress Core


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

    r40816 r42343  
    1313        self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
    1414
    15         add_role( 'grammarian', 'Grammarian', array(
    16             'read'                 => true,
    17             'edit_posts'           => true,
    18             'edit_others_posts'    => true,
    19             'edit_published_posts' => true,
    20         ) );
     15        add_role(
     16            'grammarian', 'Grammarian', array(
     17                'read'                 => true,
     18                'edit_posts'           => true,
     19                'edit_others_posts'    => true,
     20                'edit_published_posts' => true,
     21            )
     22        );
    2123
    2224        self::$grammarian_id = $factory->user->create( array( 'role' => 'grammarian' ) );
     
    3739
    3840    // helper function: return the timestamp(s) of cron jobs for the specified hook and post
    39     function _next_schedule_for_post($hook, $id) {
    40         return wp_next_scheduled('publish_future_post', array(0=>intval($id)));
     41    function _next_schedule_for_post( $hook, $id ) {
     42        return wp_next_scheduled( 'publish_future_post', array( 0 => intval( $id ) ) );
    4143    }
    4244
     
    5658        foreach ( $post_types as $post_type ) {
    5759            $post = array(
    58                 'post_author' => self::$editor_id,
    59                 'post_status' => 'publish',
     60                'post_author'  => self::$editor_id,
     61                'post_status'  => 'publish',
    6062                'post_content' => rand_str(),
    61                 'post_title' => rand_str(),
    62                 'tax_input' => array( 'post_tag' => 'tag1,tag2', 'ctax' => 'cterm1,cterm2' ),
    63                 'post_type' => $post_type
     63                'post_title'   => rand_str(),
     64                'tax_input'    => array(
     65                    'post_tag' => 'tag1,tag2',
     66                    'ctax'     => 'cterm1,cterm2',
     67                ),
     68                'post_type'    => $post_type,
    6469            );
    6570
    6671            // insert a post and make sure the ID is ok
    67             $id = wp_insert_post($post);
    68             $this->assertTrue(is_numeric($id));
    69             $this->assertTrue($id > 0);
     72            $id = wp_insert_post( $post );
     73            $this->assertTrue( is_numeric( $id ) );
     74            $this->assertTrue( $id > 0 );
    7075
    7176            // fetch the post and make sure it matches
    72             $out = get_post($id);
    73 
    74             $this->assertEquals($post['post_content'], $out->post_content);
    75             $this->assertEquals($post['post_title'], $out->post_title);
    76             $this->assertEquals($post['post_status'], $out->post_status);
    77             $this->assertEquals($post['post_author'], $out->post_author);
     77            $out = get_post( $id );
     78
     79            $this->assertEquals( $post['post_content'], $out->post_content );
     80            $this->assertEquals( $post['post_title'], $out->post_title );
     81            $this->assertEquals( $post['post_status'], $out->post_status );
     82            $this->assertEquals( $post['post_author'], $out->post_author );
    7883
    7984            // test cache state
     
    8388
    8489            update_object_term_cache( $id, $post_type );
    85             $tcache = wp_cache_get( $id, "post_tag_relationships" );
     90            $tcache = wp_cache_get( $id, 'post_tag_relationships' );
    8691            $this->assertInternalType( 'array', $tcache );
    8792            $this->assertEquals( 2, count( $tcache ) );
    8893
    89             $tcache = wp_cache_get( $id, "ctax_relationships" );
     94            $tcache = wp_cache_get( $id, 'ctax_relationships' );
    9095            if ( 'cpt' == $post_type ) {
    9196                $this->assertInternalType( 'array', $tcache );
     
    97102            wp_delete_post( $id, true );
    98103            $this->assertFalse( wp_cache_get( $id, 'posts' ) );
    99             $this->assertFalse( wp_cache_get( $id, "post_tag_relationships" ) );
    100             $this->assertFalse( wp_cache_get( $id, "ctax_relationships" ) );
     104            $this->assertFalse( wp_cache_get( $id, 'post_tag_relationships' ) );
     105            $this->assertFalse( wp_cache_get( $id, 'ctax_relationships' ) );
    101106        }
    102107
     
    107112        // insert a post with a future date, and make sure the status and cron schedule are correct
    108113
    109         $future_date = strtotime('+1 day');
     114        $future_date = strtotime( '+1 day' );
    110115
    111116        $post = array(
    112             'post_author' => self::$editor_id,
    113             'post_status' => 'publish',
     117            'post_author'  => self::$editor_id,
     118            'post_status'  => 'publish',
    114119            'post_content' => rand_str(),
    115             'post_title' => rand_str(),
    116             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date),
     120            'post_title'   => rand_str(),
     121            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date ),
    117122        );
    118123
    119124        // insert a post and make sure the ID is ok
    120         $id = $this->post_ids[] = wp_insert_post($post);
     125        $id = $this->post_ids[] = wp_insert_post( $post );
    121126        #dmp(_get_cron_array());
    122         $this->assertTrue(is_numeric($id));
    123         $this->assertTrue($id > 0);
     127        $this->assertTrue( is_numeric( $id ) );
     128        $this->assertTrue( $id > 0 );
    124129
    125130        // fetch the post and make sure it matches
    126         $out = get_post($id);
    127 
    128         $this->assertEquals($post['post_content'], $out->post_content);
    129         $this->assertEquals($post['post_title'], $out->post_title);
    130         $this->assertEquals('future', $out->post_status);
    131         $this->assertEquals($post['post_author'], $out->post_author);
    132         $this->assertEquals($post['post_date'], $out->post_date);
     131        $out = get_post( $id );
     132
     133        $this->assertEquals( $post['post_content'], $out->post_content );
     134        $this->assertEquals( $post['post_title'], $out->post_title );
     135        $this->assertEquals( 'future', $out->post_status );
     136        $this->assertEquals( $post['post_author'], $out->post_author );
     137        $this->assertEquals( $post['post_date'], $out->post_date );
    133138
    134139        // there should be a publish_future_post hook scheduled on the future date
    135         $this->assertEquals($future_date, $this->_next_schedule_for_post('publish_future_post', $id));
     140        $this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    136141    }
    137142
     
    140145
    141146        // Some magic days - one dst one not
    142         $future_date_1 = strtotime('June 21st +1 year');
    143         $future_date_2 = strtotime('Jan 11th +1 year');
    144 
     147        $future_date_1 = strtotime( 'June 21st +1 year' );
     148        $future_date_2 = strtotime( 'Jan 11th +1 year' );
    145149
    146150        $post = array(
    147             'post_author' => self::$editor_id,
    148             'post_status' => 'publish',
     151            'post_author'  => self::$editor_id,
     152            'post_status'  => 'publish',
    149153            'post_content' => rand_str(),
    150             'post_title' => rand_str(),
    151             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     154            'post_title'   => rand_str(),
     155            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date_1 ),
    152156        );
    153157
    154158        // insert a post and make sure the ID is ok
    155         $id = $this->post_ids[] = wp_insert_post($post);
     159        $id = $this->post_ids[] = wp_insert_post( $post );
    156160
    157161        // fetch the post and make sure has the correct date and status
    158         $out = get_post($id);
    159         $this->assertEquals('future', $out->post_status);
    160         $this->assertEquals($post['post_date'], $out->post_date);
     162        $out = get_post( $id );
     163        $this->assertEquals( 'future', $out->post_status );
     164        $this->assertEquals( $post['post_date'], $out->post_date );
    161165
    162166        // check that there's a publish_future_post job scheduled at the right time
    163         $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     167        $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    164168
    165169        // now save it again with a date further in the future
    166170
    167         $post['ID'] = $id;
    168         $post['post_date'] = strftime("%Y-%m-%d %H:%M:%S", $future_date_2);
    169         $post['post_date_gmt'] = NULL;
    170         wp_update_post($post);
     171        $post['ID']            = $id;
     172        $post['post_date']     = strftime( '%Y-%m-%d %H:%M:%S', $future_date_2 );
     173        $post['post_date_gmt'] = null;
     174        wp_update_post( $post );
    171175
    172176        // fetch the post again and make sure it has the new post_date
    173         $out = get_post($id);
    174         $this->assertEquals('future', $out->post_status);
    175         $this->assertEquals($post['post_date'], $out->post_date);
     177        $out = get_post( $id );
     178        $this->assertEquals( 'future', $out->post_status );
     179        $this->assertEquals( $post['post_date'], $out->post_date );
    176180
    177181        // and the correct date on the cron job
    178         $this->assertEquals($future_date_2, $this->_next_schedule_for_post('publish_future_post', $id));
     182        $this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    179183    }
    180184
     
    183187        // https://core.trac.wordpress.org/ticket/4710
    184188
    185         $future_date_1 = strtotime('+1 day');
    186         $future_date_2 = strtotime('+2 day');
     189        $future_date_1 = strtotime( '+1 day' );
     190        $future_date_2 = strtotime( '+2 day' );
    187191
    188192        $post = array(
    189             'post_author' => self::$editor_id,
    190             'post_status' => 'publish',
     193            'post_author'  => self::$editor_id,
     194            'post_status'  => 'publish',
    191195            'post_content' => rand_str(),
    192             'post_title' => rand_str(),
    193             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     196            'post_title'   => rand_str(),
     197            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date_1 ),
    194198        );
    195199
    196200        // insert a post and make sure the ID is ok
    197         $id = $this->post_ids[] = wp_insert_post($post);
     201        $id = $this->post_ids[] = wp_insert_post( $post );
    198202
    199203        // fetch the post and make sure has the correct date and status
    200         $out = get_post($id);
    201         $this->assertEquals('future', $out->post_status);
    202         $this->assertEquals($post['post_date'], $out->post_date);
     204        $out = get_post( $id );
     205        $this->assertEquals( 'future', $out->post_status );
     206        $this->assertEquals( $post['post_date'], $out->post_date );
    203207
    204208        // check that there's a publish_future_post job scheduled at the right time
    205         $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     209        $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    206210
    207211        // now save it again with a date further in the future
    208212
    209         $post['ID'] = $id;
    210         $post['post_date'] = strftime("%Y-%m-%d %H:%M:%S", $future_date_2);
    211         $post['post_date_gmt'] = NULL;
    212         wp_update_post($post);
     213        $post['ID']            = $id;
     214        $post['post_date']     = strftime( '%Y-%m-%d %H:%M:%S', $future_date_2 );
     215        $post['post_date_gmt'] = null;
     216        wp_update_post( $post );
    213217
    214218        // fetch the post again and make sure it has the new post_date
    215         $out = get_post($id);
    216         $this->assertEquals('future', $out->post_status);
    217         $this->assertEquals($post['post_date'], $out->post_date);
     219        $out = get_post( $id );
     220        $this->assertEquals( 'future', $out->post_status );
     221        $this->assertEquals( $post['post_date'], $out->post_date );
    218222
    219223        // and the correct date on the cron job
    220         $this->assertEquals($future_date_2, $this->_next_schedule_for_post('publish_future_post', $id));
     224        $this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    221225    }
    222226
     
    224228        // insert a draft post with a future date, and make sure no cron schedule is set
    225229
    226         $future_date = strtotime('+1 day');
     230        $future_date = strtotime( '+1 day' );
    227231
    228232        $post = array(
    229             'post_author' => self::$editor_id,
    230             'post_status' => 'draft',
     233            'post_author'  => self::$editor_id,
     234            'post_status'  => 'draft',
    231235            'post_content' => rand_str(),
    232             'post_title' => rand_str(),
    233             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date),
     236            'post_title'   => rand_str(),
     237            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date ),
    234238        );
    235239
    236240        // insert a post and make sure the ID is ok
    237         $id = $this->post_ids[] = wp_insert_post($post);
     241        $id = $this->post_ids[] = wp_insert_post( $post );
    238242        #dmp(_get_cron_array());
    239         $this->assertTrue(is_numeric($id));
    240         $this->assertTrue($id > 0);
     243        $this->assertTrue( is_numeric( $id ) );
     244        $this->assertTrue( $id > 0 );
    241245
    242246        // fetch the post and make sure it matches
    243         $out = get_post($id);
    244 
    245         $this->assertEquals($post['post_content'], $out->post_content);
    246         $this->assertEquals($post['post_title'], $out->post_title);
    247         $this->assertEquals('draft', $out->post_status);
    248         $this->assertEquals($post['post_author'], $out->post_author);
    249         $this->assertEquals($post['post_date'], $out->post_date);
     247        $out = get_post( $id );
     248
     249        $this->assertEquals( $post['post_content'], $out->post_content );
     250        $this->assertEquals( $post['post_title'], $out->post_title );
     251        $this->assertEquals( 'draft', $out->post_status );
     252        $this->assertEquals( $post['post_author'], $out->post_author );
     253        $this->assertEquals( $post['post_date'], $out->post_date );
    250254
    251255        // there should be a publish_future_post hook scheduled on the future date
    252         $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
     256        $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    253257
    254258    }
     
    256260    function test_vb_insert_future_change_to_draft() {
    257261        // insert a future post, then edit and change it to draft, and make sure cron gets it right
    258         $future_date_1 = strtotime('+1 day');
     262        $future_date_1 = strtotime( '+1 day' );
    259263
    260264        $post = array(
    261             'post_author' => self::$editor_id,
    262             'post_status' => 'publish',
     265            'post_author'  => self::$editor_id,
     266            'post_status'  => 'publish',
    263267            'post_content' => rand_str(),
    264             'post_title' => rand_str(),
    265             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     268            'post_title'   => rand_str(),
     269            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date_1 ),
    266270        );
    267271
    268272        // insert a post and make sure the ID is ok
    269         $id = $this->post_ids[] = wp_insert_post($post);
     273        $id = $this->post_ids[] = wp_insert_post( $post );
    270274
    271275        // fetch the post and make sure has the correct date and status
    272         $out = get_post($id);
    273         $this->assertEquals('future', $out->post_status);
    274         $this->assertEquals($post['post_date'], $out->post_date);
     276        $out = get_post( $id );
     277        $this->assertEquals( 'future', $out->post_status );
     278        $this->assertEquals( $post['post_date'], $out->post_date );
    275279
    276280        // check that there's a publish_future_post job scheduled at the right time
    277         $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     281        $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    278282
    279283        // now save it again with status set to draft
    280284
    281         $post['ID'] = $id;
     285        $post['ID']          = $id;
    282286        $post['post_status'] = 'draft';
    283         wp_update_post($post);
     287        wp_update_post( $post );
    284288
    285289        // fetch the post again and make sure it has the new post_date
    286         $out = get_post($id);
    287         $this->assertEquals('draft', $out->post_status);
    288         $this->assertEquals($post['post_date'], $out->post_date);
     290        $out = get_post( $id );
     291        $this->assertEquals( 'draft', $out->post_status );
     292        $this->assertEquals( $post['post_date'], $out->post_date );
    289293
    290294        // and the correct date on the cron job
    291         $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
     295        $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    292296    }
    293297
    294298    function test_vb_insert_future_change_status() {
    295299        // insert a future post, then edit and change the status, and make sure cron gets it right
    296         $future_date_1 = strtotime('+1 day');
    297 
    298         $statuses = array('draft', 'static', 'object', 'attachment', 'inherit', 'pending');
    299 
    300         foreach ($statuses as $status) {
     300        $future_date_1 = strtotime( '+1 day' );
     301
     302        $statuses = array( 'draft', 'static', 'object', 'attachment', 'inherit', 'pending' );
     303
     304        foreach ( $statuses as $status ) {
    301305            $post = array(
    302                 'post_author' => self::$editor_id,
    303                 'post_status' => 'publish',
     306                'post_author'  => self::$editor_id,
     307                'post_status'  => 'publish',
    304308                'post_content' => rand_str(),
    305                 'post_title' => rand_str(),
    306                 'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     309                'post_title'   => rand_str(),
     310                'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date_1 ),
    307311            );
    308312
    309313            // insert a post and make sure the ID is ok
    310             $id = $this->post_ids[] = wp_insert_post($post);
     314            $id = $this->post_ids[] = wp_insert_post( $post );
    311315
    312316            // fetch the post and make sure has the correct date and status
    313             $out = get_post($id);
    314             $this->assertEquals('future', $out->post_status);
    315             $this->assertEquals($post['post_date'], $out->post_date);
     317            $out = get_post( $id );
     318            $this->assertEquals( 'future', $out->post_status );
     319            $this->assertEquals( $post['post_date'], $out->post_date );
    316320
    317321            // check that there's a publish_future_post job scheduled at the right time
    318             $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     322            $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    319323
    320324            // now save it again with status changed
    321325
    322             $post['ID'] = $id;
     326            $post['ID']          = $id;
    323327            $post['post_status'] = $status;
    324             wp_update_post($post);
     328            wp_update_post( $post );
    325329
    326330            // fetch the post again and make sure it has the new post_date
    327             $out = get_post($id);
    328             $this->assertEquals($status, $out->post_status);
    329             $this->assertEquals($post['post_date'], $out->post_date);
     331            $out = get_post( $id );
     332            $this->assertEquals( $status, $out->post_status );
     333            $this->assertEquals( $post['post_date'], $out->post_date );
    330334
    331335            // and the correct date on the cron job
    332             $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
     336            $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    333337        }
    334338    }
     
    337341        // insert a draft post with a future date, and make sure no cron schedule is set
    338342
    339         $future_date = strtotime('+1 day');
     343        $future_date = strtotime( '+1 day' );
    340344
    341345        $post = array(
    342             'post_author' => self::$editor_id,
    343             'post_status' => 'private',
     346            'post_author'  => self::$editor_id,
     347            'post_status'  => 'private',
    344348            'post_content' => rand_str(),
    345             'post_title' => rand_str(),
    346             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date),
     349            'post_title'   => rand_str(),
     350            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date ),
    347351        );
    348352
    349353        // insert a post and make sure the ID is ok
    350         $id = $this->post_ids[] = wp_insert_post($post);
     354        $id = $this->post_ids[] = wp_insert_post( $post );
    351355        #dmp(_get_cron_array());
    352         $this->assertTrue(is_numeric($id));
    353         $this->assertTrue($id > 0);
     356        $this->assertTrue( is_numeric( $id ) );
     357        $this->assertTrue( $id > 0 );
    354358
    355359        // fetch the post and make sure it matches
    356         $out = get_post($id);
    357 
    358         $this->assertEquals($post['post_content'], $out->post_content);
    359         $this->assertEquals($post['post_title'], $out->post_title);
    360         $this->assertEquals('private', $out->post_status);
    361         $this->assertEquals($post['post_author'], $out->post_author);
    362         $this->assertEquals($post['post_date'], $out->post_date);
     360        $out = get_post( $id );
     361
     362        $this->assertEquals( $post['post_content'], $out->post_content );
     363        $this->assertEquals( $post['post_title'], $out->post_title );
     364        $this->assertEquals( 'private', $out->post_status );
     365        $this->assertEquals( $post['post_author'], $out->post_author );
     366        $this->assertEquals( $post['post_date'], $out->post_date );
    363367
    364368        // there should be a publish_future_post hook scheduled on the future date
    365         $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
     369        $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    366370    }
    367371
     
    373377
    374378        $post = array(
    375             'post_author' => self::$editor_id,
    376             'post_status' => 'public',
     379            'post_author'  => self::$editor_id,
     380            'post_status'  => 'public',
    377381            'post_content' => rand_str(),
    378             'post_title' => rand_str(),
    379             'post_date'  => '2012-02-30 00:00:00',
     382            'post_title'   => rand_str(),
     383            'post_date'    => '2012-02-30 00:00:00',
    380384        );
    381385
     
    391395    function test_vb_insert_future_change_to_private() {
    392396        // insert a future post, then edit and change it to private, and make sure cron gets it right
    393         $future_date_1 = strtotime('+1 day');
     397        $future_date_1 = strtotime( '+1 day' );
    394398
    395399        $post = array(
    396             'post_author' => self::$editor_id,
    397             'post_status' => 'publish',
     400            'post_author'  => self::$editor_id,
     401            'post_status'  => 'publish',
    398402            'post_content' => rand_str(),
    399             'post_title' => rand_str(),
    400             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     403            'post_title'   => rand_str(),
     404            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date_1 ),
    401405        );
    402406
    403407        // insert a post and make sure the ID is ok
    404         $id = $this->post_ids[] = wp_insert_post($post);
     408        $id = $this->post_ids[] = wp_insert_post( $post );
    405409
    406410        // fetch the post and make sure has the correct date and status
    407         $out = get_post($id);
    408         $this->assertEquals('future', $out->post_status);
    409         $this->assertEquals($post['post_date'], $out->post_date);
     411        $out = get_post( $id );
     412        $this->assertEquals( 'future', $out->post_status );
     413        $this->assertEquals( $post['post_date'], $out->post_date );
    410414
    411415        // check that there's a publish_future_post job scheduled at the right time
    412         $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     416        $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    413417
    414418        // now save it again with status set to draft
    415419
    416         $post['ID'] = $id;
     420        $post['ID']          = $id;
    417421        $post['post_status'] = 'private';
    418         wp_update_post($post);
     422        wp_update_post( $post );
    419423
    420424        // fetch the post again and make sure it has the new post_date
    421         $out = get_post($id);
    422         $this->assertEquals('private', $out->post_status);
    423         $this->assertEquals($post['post_date'], $out->post_date);
     425        $out = get_post( $id );
     426        $this->assertEquals( 'private', $out->post_status );
     427        $this->assertEquals( $post['post_date'], $out->post_date );
    424428
    425429        // and the correct date on the cron job
    426         $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
     430        $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    427431    }
    428432
     
    433437        $this->set_permalink_structure( '/%postname%/' );
    434438
    435         $p = wp_insert_post( array(
    436             'post_title' => '',
    437             'post_content' => 'test',
    438             'post_status' => 'publish',
    439             'post_type' => 'post',
    440         ) );
     439        $p = wp_insert_post(
     440            array(
     441                'post_title'   => '',
     442                'post_content' => 'test',
     443                'post_status'  => 'publish',
     444                'post_type'    => 'post',
     445            )
     446        );
    441447
    442448        $post = get_post( $p );
     
    451457     * @ticket 33392
    452458     */
    453     public function test_wp_insert_post_should_invalidate_post_cache_before_generating_guid_when_post_name_is_empty_and_is_generated_from_the_post_ID(){
     459    public function test_wp_insert_post_should_invalidate_post_cache_before_generating_guid_when_post_name_is_empty_and_is_generated_from_the_post_ID() {
    454460        register_post_type( 'wptests_pt' );
    455461
    456         $p = wp_insert_post( array(
    457             'post_title' => '',
    458             'post_type' => 'wptests_pt',
    459             'post_status' => 'publish',
    460         ) );
     462        $p = wp_insert_post(
     463            array(
     464                'post_title'  => '',
     465                'post_type'   => 'wptests_pt',
     466                'post_status' => 'publish',
     467            )
     468        );
    461469
    462470        $post = get_post( $p );
     
    469477     */
    470478    public function test_wp_insert_post_with_meta_input() {
    471         $post_id = wp_insert_post( array(
    472             'post_title'   => '',
    473             'post_content' => 'test',
    474             'post_status'  => 'publish',
    475             'post_type'    => 'post',
    476             'meta_input'   => array(
    477                 'hello' => 'world',
    478                 'foo'   => 'bar'
    479             )
    480         ) );
     479        $post_id = wp_insert_post(
     480            array(
     481                'post_title'   => '',
     482                'post_content' => 'test',
     483                'post_status'  => 'publish',
     484                'post_type'    => 'post',
     485                'meta_input'   => array(
     486                    'hello' => 'world',
     487                    'foo'   => 'bar',
     488                ),
     489            )
     490        );
    481491
    482492        $this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) );
     
    489499    function test_delete_future_post_cron() {
    490500        // "When I delete a future post using wp_delete_post($post->ID) it does not update the cron correctly."
    491         $future_date = strtotime('+1 day');
     501        $future_date = strtotime( '+1 day' );
    492502
    493503        $post = array(
    494             'post_author' => self::$editor_id,
    495             'post_status' => 'publish',
     504            'post_author'  => self::$editor_id,
     505            'post_status'  => 'publish',
    496506            'post_content' => rand_str(),
    497             'post_title' => rand_str(),
    498             'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date),
     507            'post_title'   => rand_str(),
     508            'post_date'    => strftime( '%Y-%m-%d %H:%M:%S', $future_date ),
    499509        );
    500510
    501511        // insert a post and make sure the ID is ok
    502         $id = $this->post_ids[] = wp_insert_post($post);
     512        $id = $this->post_ids[] = wp_insert_post( $post );
    503513
    504514        // check that there's a publish_future_post job scheduled at the right time
    505         $this->assertEquals($future_date, $this->_next_schedule_for_post('publish_future_post', $id));
     515        $this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    506516
    507517        // now delete the post and make sure the cron entry is removed
    508518        wp_delete_post( $id );
    509519
    510         $this->assertFalse($this->_next_schedule_for_post('publish_future_post', $id));
     520        $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
    511521    }
    512522
     
    518528        // might only fail if the post ID is greater than four characters
    519529
    520         $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     530        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    521531
    522532        $post = array(
    523             'post_author' => self::$editor_id,
    524             'post_status' => 'publish',
     533            'post_author'  => self::$editor_id,
     534            'post_status'  => 'publish',
    525535            'post_content' => rand_str(),
    526             'post_title' => '',
    527             'post_date' => '2007-10-31 06:15:00',
     536            'post_title'   => '',
     537            'post_date'    => '2007-10-31 06:15:00',
    528538        );
    529539
    530540        // insert a post and make sure the ID is ok
    531         $id = $this->post_ids[] = wp_insert_post($post);
    532 
    533         $plink = get_permalink($id);
     541        $id = $this->post_ids[] = wp_insert_post( $post );
     542
     543        $plink = get_permalink( $id );
    534544
    535545        // permalink should include the post ID at the end
    536         $this->assertEquals(get_option('siteurl').'/2007/10/31/'.$id.'/', $plink);
     546        $this->assertEquals( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink );
    537547    }
    538548
     
    543553        global $wpdb;
    544554
    545         $attachment = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );
    546         $page       = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );
    547         $other_att  = self::factory()->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );
     555        $attachment = self::factory()->post->create_and_get(
     556            array(
     557                'post_title' => 'some-page',
     558                'post_type'  => 'attachment',
     559            )
     560        );
     561        $page       = self::factory()->post->create_and_get(
     562            array(
     563                'post_title' => 'some-page',
     564                'post_type'  => 'page',
     565            )
     566        );
     567        $other_att  = self::factory()->post->create_and_get(
     568            array(
     569                'post_title' => 'some-other-page',
     570                'post_type'  => 'attachment',
     571            )
     572        );
    548573
    549574        $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) );
     
    579604    function test_wp_insert_post_and_wp_publish_post_with_future_date() {
    580605        $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );
    581         $post_id = self::factory()->post->create( array(
    582             'post_status' => 'publish',
    583             'post_date' => $future_date,
    584         ) );
     606        $post_id     = self::factory()->post->create(
     607            array(
     608                'post_status' => 'publish',
     609                'post_date'   => $future_date,
     610            )
     611        );
    585612
    586613        $post = get_post( $post_id );
     
    602629
    603630        $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
    604         $post = get_post( $post_id );
     631        $post    = get_post( $post_id );
    605632        $this->assertEquals( '<script>Test</script>', $post->post_title );
    606633        $this->assertEquals( 'draft', $post->post_status );
     
    608635        kses_init_filters();
    609636
    610         wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'publish' ) );
     637        wp_update_post(
     638            array(
     639                'ID'          => $post->ID,
     640                'post_status' => 'publish',
     641            )
     642        );
    611643        $post = get_post( $post->ID );
    612644        $this->assertEquals( 'Test', $post->post_title );
     
    622654
    623655        $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
    624         $post = get_post( $post_id );
     656        $post    = get_post( $post_id );
    625657        $this->assertEquals( '<script>Test</script>', $post->post_title );
    626658        $this->assertEquals( 'draft', $post->post_status );
     
    641673        global $post;
    642674        $parent_id = self::factory()->post->create();
    643         $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
     675        $post      = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
    644676        $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) );
    645677    }
     
    650682    function test_update_invalid_post_id() {
    651683        $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
    652         $post = get_post( $post_id, ARRAY_A );
     684        $post    = get_post( $post_id, ARRAY_A );
    653685
    654686        $post['ID'] = 123456789;
     
    665697        global $multipage, $pages, $numpages;
    666698        $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
    667         $post = get_post( $post_id );
     699        $post    = get_post( $post_id );
    668700        setup_postdata( $post );
    669701        $this->assertEquals( 0, $multipage );
    670         $this->assertCount(  1, $pages );
     702        $this->assertCount( 1, $pages );
    671703        $this->assertEquals( 1, $numpages );
    672704        $this->assertEquals( array( 'Page 0' ), $pages );
     
    676708        global $multipage, $pages, $numpages;
    677709        $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    678         $post = get_post( $post_id );
     710        $post    = get_post( $post_id );
    679711        setup_postdata( $post );
    680712        $this->assertEquals( 1, $multipage );
    681         $this->assertCount(  4, $pages );
     713        $this->assertCount( 4, $pages );
    682714        $this->assertEquals( 4, $numpages );
    683715        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
     
    687719        global $multipage, $pages, $numpages;
    688720        $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
    689         $post = get_post( $post_id );
     721        $post    = get_post( $post_id );
    690722        setup_postdata( $post );
    691723        $this->assertEquals( 0, $multipage );
    692         $this->assertCount(  1, $pages );
     724        $this->assertCount( 1, $pages );
    693725        $this->assertEquals( 1, $numpages );
    694726        $this->assertEquals( array( 'Page 0' ), $pages );
     
    698730        global $multipage, $pages, $numpages;
    699731        $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    700         $post = get_post( $post_id );
     732        $post    = get_post( $post_id );
    701733        setup_postdata( $post );
    702734        $this->assertEquals( 1, $multipage );
    703         $this->assertCount(  4, $pages );
     735        $this->assertCount( 4, $pages );
    704736        $this->assertEquals( 4, $numpages );
    705737        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
     
    712744        global $multipage, $pages, $numpages;
    713745        $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    714         $post = get_post( $post_id );
     746        $post    = get_post( $post_id );
    715747        setup_postdata( $post );
    716748        $this->assertEquals( 1, $multipage );
    717         $this->assertCount(  4, $pages );
     749        $this->assertCount( 4, $pages );
    718750        $this->assertEquals( 4, $numpages );
    719751        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
     
    726758        global $multipage, $pages, $numpages;
    727759        $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
    728         $post = get_post( $post_id );
     760        $post    = get_post( $post_id );
    729761        setup_postdata( $post );
    730762        $this->assertEquals( 0, $multipage );
    731         $this->assertCount(  1, $pages );
     763        $this->assertCount( 1, $pages );
    732764        $this->assertEquals( 1, $numpages );
    733765        $this->assertEquals( array( 'Page 0' ), $pages );
     
    742774        register_taxonomy( 'test_tax', 'post' );
    743775
    744         $title = rand_str();
    745         $post_data = array(
    746             'post_author' => self::$editor_id,
    747             'post_status' => 'public',
     776        $title          = rand_str();
     777        $post_data      = array(
     778            'post_author'  => self::$editor_id,
     779            'post_status'  => 'public',
    748780            'post_content' => rand_str(),
    749             'post_title' => $title,
    750             'tax_input' => array(
    751                 'test_tax' => array( 'term', 'term2', 'term3' )
    752             )
     781            'post_title'   => $title,
     782            'tax_input'    => array(
     783                'test_tax' => array( 'term', 'term2', 'term3' ),
     784            ),
    753785        );
    754786        $insert_post_id = wp_insert_post( $post_data, true, true );
    755         $this->assertTrue( ( is_int($insert_post_id) && $insert_post_id > 0 ) );
     787        $this->assertTrue( ( is_int( $insert_post_id ) && $insert_post_id > 0 ) );
    756788
    757789        $post = get_post( $insert_post_id );
     
    764796     */
    765797    function test_wp_count_posts() {
    766         $post_type = rand_str(20);
     798        $post_type = rand_str( 20 );
    767799        register_post_type( $post_type );
    768         self::factory()->post->create( array(
    769             'post_type' => $post_type,
    770             'post_author' => self::$editor_id
    771         ) );
     800        self::factory()->post->create(
     801            array(
     802                'post_type'   => $post_type,
     803                'post_author' => self::$editor_id,
     804            )
     805        );
    772806        $count = wp_count_posts( $post_type, 'readable' );
    773807        $this->assertEquals( 1, $count->publish );
     
    777811
    778812    function test_wp_count_posts_filtered() {
    779         $post_type = rand_str(20);
     813        $post_type = rand_str( 20 );
    780814        register_post_type( $post_type );
    781         self::factory()->post->create_many( 3, array(
    782             'post_type' => $post_type,
    783             'post_author' => self::$editor_id
    784         ) );
     815        self::factory()->post->create_many(
     816            3, array(
     817                'post_type'   => $post_type,
     818                'post_author' => self::$editor_id,
     819            )
     820        );
    785821        $count1 = wp_count_posts( $post_type, 'readable' );
    786822        $this->assertEquals( 3, $count1->publish );
     
    799835
    800836    function test_wp_count_posts_insert_invalidation() {
    801         $post_ids = self::factory()->post->create_many( 3 );
     837        $post_ids       = self::factory()->post->create_many( 3 );
    802838        $initial_counts = wp_count_posts();
    803839
    804         $key = array_rand( $post_ids );
    805         $_post = get_post( $post_ids[$key], ARRAY_A );
     840        $key                  = array_rand( $post_ids );
     841        $_post                = get_post( $post_ids[ $key ], ARRAY_A );
    806842        $_post['post_status'] = 'draft';
    807843        wp_insert_post( $_post );
    808         $post = get_post( $post_ids[$key] );
     844        $post = get_post( $post_ids[ $key ] );
    809845        $this->assertEquals( 'draft', $post->post_status );
    810846        $this->assertNotEquals( 'publish', $post->post_status );
     
    817853
    818854    function test_wp_count_posts_trash_invalidation() {
    819         $post_ids = self::factory()->post->create_many( 3 );
     855        $post_ids       = self::factory()->post->create_many( 3 );
    820856        $initial_counts = wp_count_posts();
    821857
    822858        $key = array_rand( $post_ids );
    823859
    824         wp_trash_post( $post_ids[$key] );
    825 
    826         $post = get_post( $post_ids[$key] );
     860        wp_trash_post( $post_ids[ $key ] );
     861
     862        $post = get_post( $post_ids[ $key ] );
    827863        $this->assertEquals( 'trash', $post->post_status );
    828864        $this->assertNotEquals( 'publish', $post->post_status );
     
    926962    function test_wp_tag_cloud_link_with_post_type() {
    927963        $post_type = 'new_post_type';
    928         $tax = 'new_tag';
     964        $tax       = 'new_tag';
    929965        register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
    930966        register_taxonomy( $tax, $post_type );
     
    933969        wp_set_object_terms( $post, rand_str(), $tax );
    934970
    935         $wp_tag_cloud = wp_tag_cloud( array(
    936             'post_type' => $post_type,
    937             'taxonomy' => $tax,
    938             'echo' => false,
    939             'link' => 'edit'
    940         ) );
     971        $wp_tag_cloud = wp_tag_cloud(
     972            array(
     973                'post_type' => $post_type,
     974                'taxonomy'  => $tax,
     975                'echo'      => false,
     976                'link'      => 'edit',
     977            )
     978        );
    941979
    942980        preg_match_all( '|href="([^"]+)"|', $wp_tag_cloud, $matches );
     
    944982
    945983        $terms = get_terms( $tax );
    946         $term = reset( $terms );
     984        $term  = reset( $terms );
    947985
    948986        foreach ( $matches[1] as $url ) {
     
    9711009            'post_title'   => "foo\xf0\x9f\x98\x88bar",
    9721010            'post_content' => "foo\xf0\x9f\x98\x8ebaz",
    973             'post_excerpt' => "foo\xf0\x9f\x98\x90bat"
     1011            'post_excerpt' => "foo\xf0\x9f\x98\x90bat",
    9741012        );
    9751013
    9761014        $expected = array(
    977             'post_title'   => "foo&#x1f608;bar",
    978             'post_content' => "foo&#x1f60e;baz",
    979             'post_excerpt' => "foo&#x1f610;bat"
     1015            'post_title'   => 'foo&#x1f608;bar',
     1016            'post_content' => 'foo&#x1f60e;baz',
     1017            'post_excerpt' => 'foo&#x1f610;bat',
    9801018        );
    9811019
     
    9841022        $post = get_post( $post_id );
    9851023
    986         foreach( $expected as $field => $value ) {
     1024        foreach ( $expected as $field => $value ) {
    9871025            $this->assertEquals( $value, $post->$field );
    9881026        }
     
    9931031     */
    9941032    function test_wp_insert_post_default_comment_ping_status_open() {
    995         $post_id = self::factory()->post->create( array(
    996             'post_author' => self::$editor_id,
    997             'post_status' => 'public',
    998             'post_content' => rand_str(),
    999             'post_title' => rand_str(),
    1000         ) );
    1001         $post = get_post( $post_id );
     1033        $post_id = self::factory()->post->create(
     1034            array(
     1035                'post_author'  => self::$editor_id,
     1036                'post_status'  => 'public',
     1037                'post_content' => rand_str(),
     1038                'post_title'   => rand_str(),
     1039            )
     1040        );
     1041        $post    = get_post( $post_id );
    10021042
    10031043        $this->assertEquals( 'open', $post->comment_status );
     
    10091049     */
    10101050    function test_wp_insert_post_page_default_comment_ping_status_closed() {
    1011         $post_id = self::factory()->post->create( array(
    1012             'post_author' => self::$editor_id,
    1013             'post_status' => 'public',
    1014             'post_content' => rand_str(),
    1015             'post_title' => rand_str(),
    1016             'post_type' => 'page',
    1017         ) );
    1018         $post = get_post( $post_id );
     1051        $post_id = self::factory()->post->create(
     1052            array(
     1053                'post_author'  => self::$editor_id,
     1054                'post_status'  => 'public',
     1055                'post_content' => rand_str(),
     1056                'post_title'   => rand_str(),
     1057                'post_type'    => 'page',
     1058            )
     1059        );
     1060        $post    = get_post( $post_id );
    10191061
    10201062        $this->assertEquals( 'closed', $post->comment_status );
     
    10261068     */
    10271069    function test_wp_insert_post_cpt_default_comment_ping_status_open() {
    1028         $post_type = rand_str(20);
     1070        $post_type = rand_str( 20 );
    10291071        register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
    1030         $post_id = self::factory()->post->create( array(
    1031             'post_author' => self::$editor_id,
    1032             'post_status' => 'public',
    1033             'post_content' => rand_str(),
    1034             'post_title' => rand_str(),
    1035             'post_type' => $post_type,
    1036         ) );
    1037         $post = get_post( $post_id );
     1072        $post_id = self::factory()->post->create(
     1073            array(
     1074                'post_author'  => self::$editor_id,
     1075                'post_status'  => 'public',
     1076                'post_content' => rand_str(),
     1077                'post_title'   => rand_str(),
     1078                'post_type'    => $post_type,
     1079            )
     1080        );
     1081        $post    = get_post( $post_id );
    10381082
    10391083        $this->assertEquals( 'open', $post->comment_status );
     
    10461090     */
    10471091    function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
    1048         $post_type = rand_str(20);
     1092        $post_type = rand_str( 20 );
    10491093        register_post_type( $post_type );
    1050         $post_id = self::factory()->post->create( array(
    1051             'post_author' => self::$editor_id,
    1052             'post_status' => 'public',
    1053             'post_content' => rand_str(),
    1054             'post_title' => rand_str(),
    1055             'post_type' => $post_type,
    1056         ) );
    1057         $post = get_post( $post_id );
     1094        $post_id = self::factory()->post->create(
     1095            array(
     1096                'post_author'  => self::$editor_id,
     1097                'post_status'  => 'public',
     1098                'post_content' => rand_str(),
     1099                'post_title'   => rand_str(),
     1100                'post_type'    => $post_type,
     1101            )
     1102        );
     1103        $post    = get_post( $post_id );
    10581104
    10591105        $this->assertEquals( 'closed', $post->comment_status );
     
    10771123
    10781124        // Create a sticky post.
    1079         $post = self::factory()->post->create_and_get( array(
    1080             'post_title'   => 'Will be changed',
    1081             'post_content' => 'Will be changed',
    1082         ) );
     1125        $post = self::factory()->post->create_and_get(
     1126            array(
     1127                'post_title'   => 'Will be changed',
     1128                'post_content' => 'Will be changed',
     1129            )
     1130        );
    10831131        stick_post( $post->ID );
    10841132
     
    10871135
    10881136        // Edit the post.
    1089         $post->post_title = 'Updated';
     1137        $post->post_title   = 'Updated';
    10901138        $post->post_content = 'Updated';
    10911139        wp_update_post( $post );
     
    11061154    function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
    11071155        // Create a sticky post.
    1108         $post = self::factory()->post->create_and_get( array(
    1109             'post_title'   => 'Will be changed',
    1110             'post_content' => 'Will be changed',
    1111         ) );
     1156        $post = self::factory()->post->create_and_get(
     1157            array(
     1158                'post_title'   => 'Will be changed',
     1159                'post_content' => 'Will be changed',
     1160            )
     1161        );
    11121162        stick_post( $post->ID );
    11131163
     
    11441194    function test_hooks_fire_when_post_gets_stuck_and_unstuck() {
    11451195        $post_id = self::factory()->post->create();
    1146         $a1 = new MockAction();
    1147         $a2 = new MockAction();
     1196        $a1      = new MockAction();
     1197        $a2      = new MockAction();
    11481198
    11491199        $this->assertFalse( is_sticky( $post_id ) );
     
    11711221     */
    11721222    function test_post_updates_without_slug_provided() {
    1173         $post_id = self::factory()->post->create( array(
    1174             'post_title'   => 'Stuff',
    1175             'post_status'  => 'publish'
    1176         ) );
     1223        $post_id = self::factory()->post->create(
     1224            array(
     1225                'post_title'  => 'Stuff',
     1226                'post_status' => 'publish',
     1227            )
     1228        );
    11771229
    11781230        $data = array(
    11791231            'ID'         => $post_id,
    1180             'post_title' => 'Stuff and Things'
     1232            'post_title' => 'Stuff and Things',
    11811233        );
    11821234
     
    11851237        $updated_post = get_post( $post_id );
    11861238        // Ensure changing the post_title didn't modify the post_name.
    1187         $this->assertEquals('stuff', $updated_post->post_name);
     1239        $this->assertEquals( 'stuff', $updated_post->post_name );
    11881240    }
    11891241
     
    12111263    function test_wp_insert_post_should_respect_post_date_gmt() {
    12121264        $post = array(
    1213             'post_author' => self::$editor_id,
    1214             'post_status' => 'publish',
    1215             'post_content' => rand_str(),
    1216             'post_title' => rand_str(),
     1265            'post_author'   => self::$editor_id,
     1266            'post_status'   => 'publish',
     1267            'post_content'  => rand_str(),
     1268            'post_title'    => rand_str(),
    12171269            'post_date_gmt' => '2014-01-01 12:00:00',
    12181270        );
    12191271
    12201272        // insert a post and make sure the ID is ok
    1221         $id = wp_insert_post($post);
    1222 
    1223         $out = get_post($id);
    1224 
    1225         $this->assertEquals($post['post_content'], $out->post_content);
    1226         $this->assertEquals($post['post_title'], $out->post_title);
    1227         $this->assertEquals($post['post_author'], $out->post_author);
    1228         $this->assertEquals(get_date_from_gmt($post['post_date_gmt']), $out->post_date);
    1229         $this->assertEquals($post['post_date_gmt'], $out->post_date_gmt);
     1273        $id = wp_insert_post( $post );
     1274
     1275        $out = get_post( $id );
     1276
     1277        $this->assertEquals( $post['post_content'], $out->post_content );
     1278        $this->assertEquals( $post['post_title'], $out->post_title );
     1279        $this->assertEquals( $post['post_author'], $out->post_author );
     1280        $this->assertEquals( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date );
     1281        $this->assertEquals( $post['post_date_gmt'], $out->post_date_gmt );
    12301282    }
    12311283
    12321284    function test_wp_delete_post_reassign_hierarchical_post_type() {
    12331285        $grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    1234         $parent_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $grandparent_page_id ) );
    1235         $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $parent_page_id ) );
     1286        $parent_page_id      = self::factory()->post->create(
     1287            array(
     1288                'post_type'   => 'page',
     1289                'post_parent' => $grandparent_page_id,
     1290            )
     1291        );
     1292        $page_id             = self::factory()->post->create(
     1293            array(
     1294                'post_type'   => 'page',
     1295                'post_parent' => $parent_page_id,
     1296            )
     1297        );
    12361298        $this->assertEquals( $parent_page_id, get_post( $page_id )->post_parent );
    12371299        wp_delete_post( $parent_page_id, true );
     
    12591321        wp_set_current_user( $this->factory()->user->create( array( 'role' => 'contributor' ) ) );
    12601322
    1261         $uuid = wp_generate_uuid4();
    1262         $post_id = wp_insert_post( array(
    1263             'post_type' => 'customize_changeset',
    1264             'post_name' => strtoupper( $uuid ),
    1265             'post_content' => wp_json_encode( $changeset_data ),
    1266         ) );
     1323        $uuid    = wp_generate_uuid4();
     1324        $post_id = wp_insert_post(
     1325            array(
     1326                'post_type'    => 'customize_changeset',
     1327                'post_name'    => strtoupper( $uuid ),
     1328                'post_content' => wp_json_encode( $changeset_data ),
     1329            )
     1330        );
    12671331        $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' );
    12681332        $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
    12691333
    12701334        $changeset_data['blogname']['value'] = 'Hola Mundo';
    1271         wp_update_post( array(
    1272             'ID' => $post_id,
    1273             'post_status' => 'draft',
    1274             'post_content' => wp_json_encode( $changeset_data ),
    1275         ) );
     1335        wp_update_post(
     1336            array(
     1337                'ID'           => $post_id,
     1338                'post_status'  => 'draft',
     1339                'post_content' => wp_json_encode( $changeset_data ),
     1340            )
     1341        );
    12761342        $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' );
    12771343        $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
    12781344
    12791345        $changeset_data['blogname']['value'] = 'Hallo Welt';
    1280         wp_update_post( array(
    1281             'ID' => $post_id,
    1282             'post_status' => 'pending',
    1283             'post_content' => wp_json_encode( $changeset_data ),
    1284         ) );
     1346        wp_update_post(
     1347            array(
     1348                'ID'           => $post_id,
     1349                'post_status'  => 'pending',
     1350                'post_content' => wp_json_encode( $changeset_data ),
     1351            )
     1352        );
    12851353        $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' );
    12861354        $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
Note: See TracChangeset for help on using the changeset viewer.