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/feed/rss2.php

    r40523 r42343  
    2020        public static function wpSetUpBeforeClass( $factory ) {
    2121                // Create a user
    22                 self::$user_id = $factory->user->create( array(
    23                         'role'         => 'author',
    24                         'user_login'   => 'test_author',
    25                         'display_name' => 'Test A. Uthor',
    26                 ) );
     22                self::$user_id = $factory->user->create(
     23                        array(
     24                                'role'         => 'author',
     25                                'user_login'   => 'test_author',
     26                                'display_name' => 'Test A. Uthor',
     27                        )
     28                );
    2729
    2830                // Create a taxonomy
    29                 self::$category = $factory->category->create_and_get( array(
    30                         'name' => 'Foo Category',
    31                         'slug' => 'foo',
    32                 ) );
     31                self::$category = $factory->category->create_and_get(
     32                        array(
     33                                'name' => 'Foo Category',
     34                                'slug' => 'foo',
     35                        )
     36                );
    3337
    3438                // Set a predictable time for testing date archives.
    … …  
    3842
    3943                // Create a few posts
    40                 self::$posts = $factory->post->create_many( $count, array(
    41                         'post_author'  => self::$user_id,
    42                         'post_date'    => self::$post_date,
    43                         'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.',
    44                         'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    45                 ) );
     44                self::$posts = $factory->post->create_many(
     45                        $count, array(
     46                                'post_author'  => self::$user_id,
     47                                'post_date'    => self::$post_date,
     48                                'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.',
     49                                'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
     50                        )
     51                );
    4652
    4753                // Assign a category to those posts
    … …  
    5763                parent::setUp();
    5864
    59                 $this->post_count = (int) get_option( 'posts_per_rss' );
     65                $this->post_count   = (int) get_option( 'posts_per_rss' );
    6066                $this->excerpt_only = get_option( 'rss_use_excerpt' );
    6167                // this seems to break something
    … …  
    7480                global $post;
    7581                try {
    76                         @require(ABSPATH . 'wp-includes/feed-rss2.php');
     82                        @require( ABSPATH . 'wp-includes/feed-rss2.php' );
    7783                        $out = ob_get_clean();
    78                 } catch (Exception $e) {
     84                } catch ( Exception $e ) {
    7985                        $out = ob_get_clean();
    8086                        throw($e);
    … …  
    9096                $this->go_to( '/?feed=rss2' );
    9197                $feed = $this->do_rss2();
    92                 $xml = xml_to_array( $feed );
     98                $xml  = xml_to_array( $feed );
    9399
    94100                // Get the <rss> child element of <xml>.
    … …  
    109115        /**
    110116         * [test_channel_element description]
     117         *
    111118         * @return [type] [description]
    112119         */
    … …  
    114121                $this->go_to( '/?feed=rss2' );
    115122                $feed = $this->do_rss2();
    116                 $xml = xml_to_array( $feed );
     123                $xml  = xml_to_array( $feed );
    117124
    118125                // get the rss -> channel element
    … …  
    138145        /**
    139146         * Test that translated feeds have a valid listed date.
     147         *
    140148         * @group 39141
    141149         */
    … …  
    145153                $locale = clone $GLOBALS['wp_locale'];
    146154
    147                 $locale->weekday[2] = 'Tuesday_Translated';
    148                 $locale->weekday_abbrev[ 'Tuesday_Translated' ] = 'Tue_Translated';
     155                $locale->weekday[2]                           = 'Tuesday_Translated';
     156                $locale->weekday_abbrev['Tuesday_Translated'] = 'Tue_Translated';
    149157
    150158                $GLOBALS['wp_locale'] = $locale;
    … …  
    166174                $this->go_to( '/?feed=rss2' );
    167175                $feed = $this->do_rss2();
    168                 $xml = xml_to_array( $feed );
     176                $xml  = xml_to_array( $feed );
    169177
    170178                // Get all the <item> child elements of the <channel> element
    … …  
    181189
    182190                        // Get post for comparison
    183                         $guid = xml_find( $items[$key]['child'], 'guid' );
     191                        $guid = xml_find( $items[ $key ]['child'], 'guid' );
    184192                        preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches );
    185193                        $post = get_post( $matches[1] );
    186194
    187195                        // Title
    188                         $title = xml_find( $items[$key]['child'], 'title' );
     196                        $title = xml_find( $items[ $key ]['child'], 'title' );
    189197                        $this->assertEquals( $post->post_title, $title[0]['content'] );
    190198
    191199                        // Link
    192                         $link = xml_find( $items[$key]['child'], 'link' );
     200                        $link = xml_find( $items[ $key ]['child'], 'link' );
    193201                        $this->assertEquals( get_permalink( $post ), $link[0]['content'] );
    194202
    195203                        // Comment link
    196                         $comments_link = xml_find( $items[$key]['child'], 'comments' );
     204                        $comments_link = xml_find( $items[ $key ]['child'], 'comments' );
    197205                        $this->assertEquals( get_permalink( $post ) . '#respond', $comments_link[0]['content'] );
    198206
    199207                        // Pub date
    200                         $pubdate = xml_find( $items[$key]['child'], 'pubDate' );
     208                        $pubdate = xml_find( $items[ $key ]['child'], 'pubDate' );
    201209                        $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) );
    202210
    203211                        // Author
    204                         $creator = xml_find( $items[$key]['child'], 'dc:creator' );
    205                         $user = new WP_User( $post->post_author );
     212                        $creator = xml_find( $items[ $key ]['child'], 'dc:creator' );
     213                        $user    = new WP_User( $post->post_author );
    206214                        $this->assertEquals( $user->display_name, $creator[0]['content'] );
    207215
    208216                        // Categories (perhaps multiple)
    209                         $categories = xml_find( $items[$key]['child'], 'category' );
    210                         $cats = array();
     217                        $categories = xml_find( $items[ $key ]['child'], 'category' );
     218                        $cats       = array();
    211219                        foreach ( get_the_category( $post->ID ) as $term ) {
    212220                                $cats[] = $term->name;
    … …  
    225233                        // ..with the same names
    226234                        foreach ( $cats as $id => $cat ) {
    227                                 $this->assertEquals( $cat, $categories[$id]['content'] );
     235                                $this->assertEquals( $cat, $categories[ $id ]['content'] );
    228236                        }
    229237
    230238                        // GUID
    231                         $guid = xml_find( $items[$key]['child'], 'guid' );
     239                        $guid = xml_find( $items[ $key ]['child'], 'guid' );
    232240                        $this->assertEquals( 'false', $guid[0]['attributes']['isPermaLink'] );
    233241                        $this->assertEquals( $post->guid, $guid[0]['content'] );
    … …  
    235243                        // Description / Excerpt
    236244                        if ( ! empty( $post->post_excerpt ) ) {
    237                                 $description = xml_find( $items[$key]['child'], 'description' );
     245                                $description = xml_find( $items[ $key ]['child'], 'description' );
    238246                                $this->assertEquals( trim( $post->post_excerpt ), trim( $description[0]['content'] ) );
    239247                        }
    … …  
    241249                        // Post content
    242250                        if ( ! $this->excerpt_only ) {
    243                                 $content = xml_find( $items[$key]['child'], 'content:encoded' );
     251                                $content = xml_find( $items[ $key ]['child'], 'content:encoded' );
    244252                                $this->assertEquals( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) );
    245253                        }
    246254
    247255                        // Comment rss
    248                         $comment_rss = xml_find( $items[$key]['child'], 'wfw:commentRss' );
     256                        $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' );
    249257                        $this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID ) ), $comment_rss[0]['content'] );
    250258                }
    … …  
    259267                $this->go_to( '/?feed=rss2' );
    260268                $feed = $this->do_rss2();
    261                 $xml = xml_to_array( $feed );
     269                $xml  = xml_to_array( $feed );
    262270
    263271                // get all the rss -> channel -> item elements
    … …  
    267275                foreach ( $items as $key => $item ) {
    268276                        // Get post for comparison
    269                         $guid = xml_find( $items[$key]['child'], 'guid' );
     277                        $guid = xml_find( $items[ $key ]['child'], 'guid' );
    270278                        preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches );
    271279                        $post = get_post( $matches[1] );
Note: See TracChangeset for help on using the changeset viewer.