Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 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/term/wpSetObjectTerms.php

    r46586 r47122  
    1919        $hier     = rand_str( 10 );
    2020
    21         // Register taxonomies
     21        // Register taxonomies.
    2222        register_taxonomy( $non_hier, array() );
    2323        register_taxonomy( $hier, array( 'hierarchical' => true ) );
     
    113113        foreach ( $ids as $id ) {
    114114            $tt = wp_set_object_terms( $id, array_values( $term_id ), $this->taxonomy );
    115             // should return three term taxonomy ids
     115            // Should return three term taxonomy IDs.
    116116            $this->assertEquals( 3, count( $tt ) );
    117117        }
    118118
    119         // each term should be associated with every post
     119        // Each term should be associated with every post.
    120120        foreach ( $term_id as $term => $id ) {
    121121            $actual = get_objects_in_term( $id, $this->taxonomy );
     
    123123        }
    124124
    125         // each term should have a count of 5
     125        // Each term should have a count of 5.
    126126        foreach ( array_keys( $term_id ) as $term ) {
    127127            $t = get_term_by( 'name', $term, $this->taxonomy );
     
    141141        foreach ( $ids as $id ) {
    142142            $tt = wp_set_object_terms( $id, $terms, $this->taxonomy );
    143             // should return three term taxonomy ids
     143            // Should return three term taxonomy IDs.
    144144            $this->assertEquals( 3, count( $tt ) );
    145             // remember which term has which term_id
     145            // Remember which term has which term_id.
    146146            for ( $i = 0; $i < 3; $i++ ) {
    147147                $term                    = get_term_by( 'name', $terms[ $i ], $this->taxonomy );
     
    150150        }
    151151
    152         // each term should be associated with every post
     152        // Each term should be associated with every post.
    153153        foreach ( $term_id as $term => $id ) {
    154154            $actual = get_objects_in_term( $id, $this->taxonomy );
     
    156156        }
    157157
    158         // each term should have a count of 5
     158        // Each term should have a count of 5.
    159159        foreach ( $terms as $term ) {
    160160            $t = get_term_by( 'name', $term, $this->taxonomy );
     
    164164
    165165    function test_set_object_terms_invalid() {
    166         // bogus taxonomy
     166        // Bogus taxonomy.
    167167        $result = wp_set_object_terms( self::$post_ids[0], array( rand_str() ), rand_str() );
    168168        $this->assertWPError( $result );
     
    244244    }
    245245
     246    /**
     247     * Set some terms on an object; then change them while leaving one intact.
     248     */
    246249    function test_change_object_terms_by_id() {
    247         // set some terms on an object; then change them while leaving one intact
    248 
    249250        $post_id = self::$post_ids[0];
    250251
    251         // first set: 3 terms
     252        // First set: 3 terms.
    252253        $terms_1 = array();
    253254        for ( $i = 0; $i < 3; $i++ ) {
     
    258259        }
    259260
    260         // second set: one of the original terms, plus one new term
     261        // Second set: one of the original terms, plus one new term.
    261262        $terms_2    = array();
    262263        $terms_2[0] = $terms_1[1];
     
    266267        $terms_2[1] = $result['term_id'];
    267268
    268         // set the initial terms
     269        // Set the initial terms.
    269270        $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy );
    270271        $this->assertEquals( 3, count( $tt_1 ) );
    271272
    272         // make sure they're correct
     273        // Make sure they're correct.
    273274        $terms = wp_get_object_terms(
    274275            $post_id,
     
    281282        $this->assertEquals( $terms_1, $terms );
    282283
    283         // change the terms
     284        // Change the terms.
    284285        $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy );
    285286        $this->assertEquals( 2, count( $tt_2 ) );
    286287
    287         // make sure they're correct
     288        // Make sure they're correct.
    288289        $terms = wp_get_object_terms(
    289290            $post_id,
     
    296297        $this->assertEquals( $terms_2, $terms );
    297298
    298         // make sure the tt id for 'bar' matches
     299        // Make sure the term taxonomy ID for 'bar' matches.
    299300        $this->assertEquals( $tt_1[1], $tt_2[0] );
    300301
    301302    }
    302303
     304    /**
     305     * Set some terms on an object; then change them while leaving one intact.
     306     */
    303307    function test_change_object_terms_by_name() {
    304         // set some terms on an object; then change them while leaving one intact
    305 
    306308        $post_id = self::$post_ids[0];
    307309
     
    309311        $terms_2 = array( 'bar', 'bing' );
    310312
    311         // set the initial terms
     313        // Set the initial terms.
    312314        $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy );
    313315        $this->assertEquals( 3, count( $tt_1 ) );
    314316
    315         // make sure they're correct
     317        // Make sure they're correct.
    316318        $terms = wp_get_object_terms(
    317319            $post_id,
     
    324326        $this->assertEquals( $terms_1, $terms );
    325327
    326         // change the terms
     328        // Change the terms.
    327329        $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy );
    328330        $this->assertEquals( 2, count( $tt_2 ) );
    329331
    330         // make sure they're correct
     332        // Make sure they're correct.
    331333        $terms = wp_get_object_terms(
    332334            $post_id,
     
    339341        $this->assertEquals( $terms_2, $terms );
    340342
    341         // make sure the tt id for 'bar' matches
     343        // Make sure the term taxonomy ID for 'bar' matches.
    342344        $this->assertEquals( $tt_1[1], $tt_2[0] );
    343345
Note: See TracChangeset for help on using the changeset viewer.