Make WordPress Core


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

    r36159 r42343  
    1212        public function test_get_adjacent_post() {
    1313                // Need some sample posts to test adjacency
    14                 $post_one = self::factory()->post->create_and_get( array(
    15                         'post_title' => 'First',
    16                         'post_date' => '2012-01-01 12:00:00'
    17                 ) );
    18 
    19                 $post_two = self::factory()->post->create_and_get( array(
    20                         'post_title' => 'Second',
    21                         'post_date' => '2012-02-01 12:00:00'
    22                 ) );
    23 
    24                 $post_three = self::factory()->post->create_and_get( array(
    25                         'post_title' => 'Third',
    26                         'post_date' => '2012-03-01 12:00:00'
    27                 ) );
    28 
    29                 $post_four = self::factory()->post->create_and_get( array(
    30                         'post_title' => 'Fourth',
    31                         'post_date' => '2012-04-01 12:00:00'
    32                 ) );
     14                $post_one = self::factory()->post->create_and_get(
     15                        array(
     16                                'post_title' => 'First',
     17                                'post_date'  => '2012-01-01 12:00:00',
     18                        )
     19                );
     20
     21                $post_two = self::factory()->post->create_and_get(
     22                        array(
     23                                'post_title' => 'Second',
     24                                'post_date'  => '2012-02-01 12:00:00',
     25                        )
     26                );
     27
     28                $post_three = self::factory()->post->create_and_get(
     29                        array(
     30                                'post_title' => 'Third',
     31                                'post_date'  => '2012-03-01 12:00:00',
     32                        )
     33                );
     34
     35                $post_four = self::factory()->post->create_and_get(
     36                        array(
     37                                'post_title' => 'Fourth',
     38                                'post_date'  => '2012-04-01 12:00:00',
     39                        )
     40                );
    3341
    3442                // Assign some terms
    35                 wp_set_object_terms( $post_one->ID, 'wordpress', 'category', false );
    36                 wp_set_object_terms( $post_three->ID, 'wordpress', 'category', false );
     43                wp_set_object_terms( $post_one->ID, 'WordPress', 'category', false );
     44                wp_set_object_terms( $post_three->ID, 'WordPress', 'category', false );
    3745
    3846                wp_set_object_terms( $post_two->ID, 'plugins', 'post_tag', false );
     
    8593                // Bump term_taxonomy to mimic shared term offsets.
    8694                global $wpdb;
    87                 $wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) );
    88 
    89                 $include = self::factory()->term->create( array(
    90                         'taxonomy' => 'category',
    91                         'name' => 'Include',
    92                 ) );
     95                $wpdb->insert(
     96                        $wpdb->term_taxonomy, array(
     97                                'taxonomy'    => 'foo',
     98                                'term_id'     => 12345,
     99                                'description' => '',
     100                        )
     101                );
     102
     103                $include = self::factory()->term->create(
     104                        array(
     105                                'taxonomy' => 'category',
     106                                'name'     => 'Include',
     107                        )
     108                );
    93109                $exclude = self::factory()->category->create();
    94110
    95                 $one = self::factory()->post->create_and_get( array(
    96                         'post_date' => '2012-01-01 12:00:00',
    97                         'post_category' => array( $include, $exclude ),
    98                 ) );
    99 
    100                 $two = self::factory()->post->create_and_get( array(
    101                         'post_date' => '2012-01-02 12:00:00',
    102                         'post_category' => array(),
    103                 ) );
    104 
    105                 $three = self::factory()->post->create_and_get( array(
    106                         'post_date' => '2012-01-03 12:00:00',
    107                         'post_category' => array( $include, $exclude ),
    108                 ) );
    109 
    110                 $four = self::factory()->post->create_and_get( array(
    111                         'post_date' => '2012-01-04 12:00:00',
    112                         'post_category' => array( $include ),
    113                 ) );
    114 
    115                 $five = self::factory()->post->create_and_get( array(
    116                         'post_date' => '2012-01-05 12:00:00',
    117                         'post_category' => array( $include, $exclude ),
    118                 ) );
     111                $one = self::factory()->post->create_and_get(
     112                        array(
     113                                'post_date'     => '2012-01-01 12:00:00',
     114                                'post_category' => array( $include, $exclude ),
     115                        )
     116                );
     117
     118                $two = self::factory()->post->create_and_get(
     119                        array(
     120                                'post_date'     => '2012-01-02 12:00:00',
     121                                'post_category' => array(),
     122                        )
     123                );
     124
     125                $three = self::factory()->post->create_and_get(
     126                        array(
     127                                'post_date'     => '2012-01-03 12:00:00',
     128                                'post_category' => array( $include, $exclude ),
     129                        )
     130                );
     131
     132                $four = self::factory()->post->create_and_get(
     133                        array(
     134                                'post_date'     => '2012-01-04 12:00:00',
     135                                'post_category' => array( $include ),
     136                        )
     137                );
     138
     139                $five = self::factory()->post->create_and_get(
     140                        array(
     141                                'post_date'     => '2012-01-05 12:00:00',
     142                                'post_category' => array( $include, $exclude ),
     143                        )
     144                );
    119145
    120146                // First post
     
    153179                register_taxonomy( 'wptests_tax', 'post' );
    154180
    155                 $t = self::factory()->term->create( array(
    156                         'taxonomy' => 'wptests_tax',
    157                 ) );
     181                $t = self::factory()->term->create(
     182                        array(
     183                                'taxonomy' => 'wptests_tax',
     184                        )
     185                );
    158186
    159187                $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
     
    164192
    165193                // Fake current page.
    166                 $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
     194                $_post           = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
    167195                $GLOBALS['post'] = get_post( $p1 );
    168196
     
    185213                register_taxonomy( 'wptests_tax', 'post' );
    186214
    187                 $t = self::factory()->term->create( array(
    188                         'taxonomy' => 'wptests_tax',
    189                 ) );
     215                $t = self::factory()->term->create(
     216                        array(
     217                                'taxonomy' => 'wptests_tax',
     218                        )
     219                );
    190220
    191221                $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
     
    199229
    200230                // Fake current page.
    201                 $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
     231                $_post           = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
    202232                $GLOBALS['post'] = get_post( $p1 );
    203233
     
    220250                register_taxonomy( 'wptests_tax', 'post' );
    221251
    222                 $terms = self::factory()->term->create_many( 2, array(
    223                         'taxonomy' => 'wptests_tax',
    224                 ) );
     252                $terms = self::factory()->term->create_many(
     253                        2, array(
     254                                'taxonomy' => 'wptests_tax',
     255                        )
     256                );
    225257
    226258                $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
Note: See TracChangeset for help on using the changeset viewer.