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/atom.php

    r38927 r42343  
    1919        public static function wpSetUpBeforeClass( $factory ) {
    2020                // Create a user
    21                 self::$user_id = $factory->user->create( array(
    22                         'role'         => 'author',
    23                         'user_login'   => 'test_author',
    24                         'display_name' => 'Test A. Uthor',
    25                 ) );
     21                self::$user_id = $factory->user->create(
     22                        array(
     23                                'role'         => 'author',
     24                                'user_login'   => 'test_author',
     25                                'display_name' => 'Test A. Uthor',
     26                        )
     27                );
    2628
    2729                // Create a taxonomy
    28                 self::$category = self::factory()->category->create_and_get( array(
    29                         'name' => 'Test Category',
    30                         'slug' => 'test-cat',
    31                 ) );
     30                self::$category = self::factory()->category->create_and_get(
     31                        array(
     32                                'name' => 'Test Category',
     33                                'slug' => 'test-cat',
     34                        )
     35                );
    3236
    3337                $count = get_option( 'posts_per_rss' ) + 1;
    3438
    3539                // Create a few posts
    36                 self::$posts = $factory->post->create_many( $count, array(
    37                         'post_author'  => self::$user_id,
    38                         '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.',
    39                         'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    40                 ) );
     40                self::$posts = $factory->post->create_many(
     41                        $count, array(
     42                                'post_author'  => self::$user_id,
     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                        )
     46                );
    4147
    4248                // Assign a category to those posts
     
    5359                parent::setUp();
    5460
    55                 $this->post_count = (int) get_option( 'posts_per_rss' );
     61                $this->post_count   = (int) get_option( 'posts_per_rss' );
    5662                $this->excerpt_only = get_option( 'rss_use_excerpt' );
    5763        }
     
    8187                $this->go_to( '/?feed=atom' );
    8288                $feed = $this->do_atom();
    83                 $xml = xml_to_array( $feed );
     89                $xml  = xml_to_array( $feed );
    8490
    8591                // Get the <feed> child element of <xml>.
     
    9298                $this->assertEquals( 'http://www.w3.org/2005/Atom', $atom[0]['attributes']['xmlns'] );
    9399                $this->assertEquals( 'http://purl.org/syndication/thread/1.0', $atom[0]['attributes']['xmlns:thr'] );
    94                 $this->assertEquals( site_url( '/wp-atom.php' ) , $atom[0]['attributes']['xml:base'] );
     100                $this->assertEquals( site_url( '/wp-atom.php' ), $atom[0]['attributes']['xml:base'] );
    95101
    96102                // Verify the <feed> element is present and contains a <title> child element.
     
    125131                $this->go_to( '/?feed=atom' );
    126132                $feed = $this->do_atom();
    127                 $xml = xml_to_array( $feed );
     133                $xml  = xml_to_array( $feed );
    128134
    129135                // Get all the <entry> child elements of the <feed> element.
     
    140146
    141147                        // Get post for comparison
    142                         $id = xml_find( $entries[$key]['child'], 'id' );
     148                        $id = xml_find( $entries[ $key ]['child'], 'id' );
    143149                        preg_match( '/\?p=(\d+)/', $id[0]['content'], $matches );
    144150                        $post = get_post( $matches[1] );
    145151
    146152                        // Author
    147                         $author = xml_find( $entries[$key]['child'], 'author', 'name' );
    148                         $user = new WP_User( $post->post_author );
     153                        $author = xml_find( $entries[ $key ]['child'], 'author', 'name' );
     154                        $user   = new WP_User( $post->post_author );
    149155                        $this->assertEquals( $user->display_name, $author[0]['content'] );
    150156
    151157                        // Title
    152                         $title = xml_find( $entries[$key]['child'], 'title' );
     158                        $title = xml_find( $entries[ $key ]['child'], 'title' );
    153159                        $this->assertEquals( $post->post_title, $title[0]['content'] );
    154160
    155161                        // Link rel="alternate"
    156                         $link_alts = xml_find( $entries[$key]['child'], 'link' );
     162                        $link_alts = xml_find( $entries[ $key ]['child'], 'link' );
    157163                        foreach ( $link_alts as $link_alt ) {
    158164                                if ( 'alternate' == $link_alt['attributes']['rel'] ) {
     
    162168
    163169                        // Id
    164                         $guid = xml_find( $entries[$key]['child'], 'id' );
     170                        $guid = xml_find( $entries[ $key ]['child'], 'id' );
    165171                        $this->assertEquals( $post->guid, $id[0]['content'] );
    166172
    167173                        // Updated
    168                         $updated = xml_find( $entries[$key]['child'], 'updated' );
     174                        $updated = xml_find( $entries[ $key ]['child'], 'updated' );
    169175                        $this->assertEquals( strtotime( $post->post_modified_gmt ), strtotime( $updated[0]['content'] ) );
    170176
    171177                        // Published
    172                         $published = xml_find( $entries[$key]['child'], 'published' );
     178                        $published = xml_find( $entries[ $key ]['child'], 'published' );
    173179                        $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $published[0]['content'] ) );
    174180
     
    177183                                $terms[] = $term->name;
    178184                        }
    179                         $categories = xml_find( $entries[$key]['child'], 'category' );
     185                        $categories = xml_find( $entries[ $key ]['child'], 'category' );
    180186                        foreach ( $categories as $category ) {
    181187                                $this->assertTrue( in_array( $category['attributes']['term'], $terms ) );
     
    185191                        // Content
    186192                        if ( ! $this->excerpt_only ) {
    187                                 $content = xml_find( $entries[$key]['child'], 'content' );
     193                                $content = xml_find( $entries[ $key ]['child'], 'content' );
    188194                                $this->assertEquals( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) );
    189195                        }
    190196
    191197                        // Link rel="replies"
    192                         $link_replies = xml_find( $entries[$key]['child'], 'link' );
     198                        $link_replies = xml_find( $entries[ $key ]['child'], 'link' );
    193199                        foreach ( $link_replies as $link_reply ) {
    194200                                if ( 'replies' == $link_reply['attributes']['rel'] && 'application/atom+xml' == $link_reply['attributes']['type'] ) {
Note: See TracChangeset for help on using the changeset viewer.