Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/feed/rss2.php

    r46586 r47122  
    1919     */
    2020    public static function wpSetUpBeforeClass( $factory ) {
    21         // Create a user
     21        // Create a user.
    2222        self::$user_id = $factory->user->create(
    2323            array(
     
    2828        );
    2929
    30         // Create a taxonomy
     30        // Create a taxonomy.
    3131        self::$category = $factory->category->create_and_get(
    3232            array(
     
    4242
    4343        self::$posts = array();
    44         // Create a few posts
     44        // Create a few posts.
    4545        for ( $i = 1; $i <= $count; $i++ ) {
    4646            self::$posts[] = $factory->post->create(
     
    5555        }
    5656
    57         // Assign a category to those posts
     57        // Assign a category to those posts.
    5858        foreach ( self::$posts as $post ) {
    5959            wp_set_object_terms( $post, self::$category->slug, 'category' );
     
    6969        $this->post_count   = (int) get_option( 'posts_per_rss' );
    7070        $this->excerpt_only = get_option( 'rss_use_excerpt' );
    71         // this seems to break something
     71        // This seems to break something.
    7272        update_option( 'use_smilies', false );
    7373
     
    114114        $this->assertEquals( 'http://purl.org/dc/elements/1.1/', $rss[0]['attributes']['xmlns:dc'] );
    115115
    116         // rss should have exactly one child element (channel)
     116        // RSS should have exactly one child element (channel).
    117117        $this->assertEquals( 1, count( $rss[0]['child'] ) );
    118118    }
     
    128128        $xml  = xml_to_array( $feed );
    129129
    130         // get the rss -> channel element
     130        // Get the rss -> channel element.
    131131        $channel = xml_find( $xml, 'rss', 'channel' );
    132132
    133         // The channel should be free of attributes
     133        // The channel should be free of attributes.
    134134        $this->assertTrue( empty( $channel[0]['attributes'] ) );
    135135
    136         // Verify the channel is present and contains a title child element
     136        // Verify the channel is present and contains a title child element.
    137137        $title = xml_find( $xml, 'rss', 'channel', 'title' );
    138138        $this->assertEquals( get_option( 'blogname' ), $title[0]['content'] );
     
    181181        $xml  = xml_to_array( $feed );
    182182
    183         // Get all the <item> child elements of the <channel> element
     183        // Get all the <item> child elements of the <channel> element.
    184184        $items = xml_find( $xml, 'rss', 'channel', 'item' );
    185185
     
    187187        $this->assertCount( $this->post_count, $items );
    188188
    189         // We Really only need to test X number of items unless the content is different
     189        // We really only need to test X number of items unless the content is different.
    190190        $items = array_slice( $items, 1 );
    191191
    192         // Check each of the desired entries against the known post data
     192        // Check each of the desired entries against the known post data.
    193193        foreach ( $items as $key => $item ) {
    194194
    195             // Get post for comparison
     195            // Get post for comparison.
    196196            $guid = xml_find( $items[ $key ]['child'], 'guid' );
    197197            preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches );
    198198            $post = get_post( $matches[1] );
    199199
    200             // Title
     200            // Title.
    201201            $title = xml_find( $items[ $key ]['child'], 'title' );
    202202            $this->assertEquals( $post->post_title, $title[0]['content'] );
    203203
    204             // Link
     204            // Link.
    205205            $link = xml_find( $items[ $key ]['child'], 'link' );
    206206            $this->assertEquals( get_permalink( $post ), $link[0]['content'] );
    207207
    208             // Comment link
     208            // Comment link.
    209209            $comments_link = xml_find( $items[ $key ]['child'], 'comments' );
    210210            $this->assertEquals( get_permalink( $post ) . '#respond', $comments_link[0]['content'] );
    211211
    212             // Pub date
     212            // Pub date.
    213213            $pubdate = xml_find( $items[ $key ]['child'], 'pubDate' );
    214214            $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) );
    215215
    216             // Author
     216            // Author.
    217217            $creator = xml_find( $items[ $key ]['child'], 'dc:creator' );
    218218            $user    = new WP_User( $post->post_author );
    219219            $this->assertEquals( $user->display_name, $creator[0]['content'] );
    220220
    221             // Categories (perhaps multiple)
     221            // Categories (perhaps multiple).
    222222            $categories = xml_find( $items[ $key ]['child'], 'category' );
    223223            $cats       = array();
     
    233233            }
    234234            $cats = array_filter( $cats );
    235             // Should be the same number of categories
     235            // Should be the same number of categories.
    236236            $this->assertEquals( count( $cats ), count( $categories ) );
    237237
    238             // ..with the same names
     238            // ..with the same names.
    239239            foreach ( $cats as $id => $cat ) {
    240240                $this->assertEquals( $cat, $categories[ $id ]['content'] );
    241241            }
    242242
    243             // GUID
     243            // GUID.
    244244            $guid = xml_find( $items[ $key ]['child'], 'guid' );
    245245            $this->assertEquals( 'false', $guid[0]['attributes']['isPermaLink'] );
    246246            $this->assertEquals( $post->guid, $guid[0]['content'] );
    247247
    248             // Description / Excerpt
     248            // Description / Excerpt.
    249249            if ( ! empty( $post->post_excerpt ) ) {
    250250                $description = xml_find( $items[ $key ]['child'], 'description' );
     
    252252            }
    253253
    254             // Post content
     254            // Post content.
    255255            if ( ! $this->excerpt_only ) {
    256256                $content = xml_find( $items[ $key ]['child'], 'content:encoded' );
     
    258258            }
    259259
    260             // Comment rss
     260            // Comment RSS.
    261261            $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' );
    262262            $this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID ) ), $comment_rss[0]['content'] );
     
    274274        $xml  = xml_to_array( $feed );
    275275
    276         // get all the rss -> channel -> item elements
     276        // Get all the rss -> channel -> item elements.
    277277        $items = xml_find( $xml, 'rss', 'channel', 'item' );
    278278
    279         // check each of the items against the known post data
     279        // Check each of the items against the known post data.
    280280        foreach ( $items as $key => $item ) {
    281             // Get post for comparison
     281            // Get post for comparison.
    282282            $guid = xml_find( $items[ $key ]['child'], 'guid' );
    283283            preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches );
    284284            $post = get_post( $matches[1] );
    285285
    286             // comment link
     286            // Comment link.
    287287            $comments_link = xml_find( $items[ $key ]['child'], 'comments' );
    288288            $this->assertEmpty( $comments_link );
    289289
    290             // comment rss
     290            // Comment RSS.
    291291            $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' );
    292292            $this->assertEmpty( $comment_rss );
     
    359359     */
    360360    function test_valid_main_comment_feed_endpoint() {
    361         // Generate a bunch of comments
     361        // Generate a bunch of comments.
    362362        foreach ( self::$posts as $post ) {
    363363            self::factory()->comment->create_post_comments( $post, 3 );
     
    448448     */
    449449    function test_valid_search_feed_endpoint() {
    450         // An example of an valid search feed endpoint
     450        // An example of an valid search feed endpoint.
    451451        $this->go_to( '?s=Lorem&feed=rss' );
    452452
Note: See TracChangeset for help on using the changeset viewer.