Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 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/xmlrpc/wp/editPost.php

    r46586 r47122  
    146146        $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    147147
    148         // create attachment
     148        // Create attachment.
    149149        $filename      = ( DIR_TESTDATA . '/images/a2-small.jpg' );
    150150        $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    151151
    152         // add post thumbnail to post that does not have one
     152        // Add post thumbnail to post that does not have one.
    153153        $post2  = array( 'post_thumbnail' => $attachment_id );
    154154        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) );
     
    156156        $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    157157
    158         // fetch the post to verify that it appears
     158        // Fetch the post to verify that it appears.
    159159        $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) );
    160160        $this->assertNotIXRError( $result );
     
    163163        $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] );
    164164
    165         // edit the post without supplying a post_thumbnail and check that it didn't change
     165        // Edit the post without supplying a post_thumbnail and check that it didn't change.
    166166        $post3  = array( 'post_content' => 'Updated post' );
    167167        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) );
     
    169169        $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    170170
    171         // create another attachment
     171        // Create another attachment.
    172172        $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    173173
    174         // change the post's post_thumbnail
     174        // Change the post's post_thumbnail.
    175175        $post4  = array( 'post_thumbnail' => $attachment2_id );
    176176        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) );
     
    178178        $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    179179
    180         // unset the post's post_thumbnail
     180        // Unset the post's post_thumbnail.
    181181        $post5  = array( 'post_thumbnail' => '' );
    182182        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) );
     
    184184        $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    185185
    186         // use invalid ID
     186        // Use invalid ID.
    187187        $post6  = array( 'post_thumbnail' => 398420983409 );
    188188        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) );
     
    250250
    251251    function test_password_transition_unsticky() {
    252         // when transitioning to private status or adding a post password, post should be un-stuck
     252        // When transitioning to private status or adding a post password, post should be un-stuck.
    253253        $editor_id = $this->make_user_by_role( 'editor' );
    254254        $post_id   = self::factory()->post->create( array( 'post_author' => $editor_id ) );
     
    320320        $this->assertNotIXRError( $result );
    321321
    322         // Make sure that the post status is still inherit
     322        // Make sure that the post status is still inherit.
    323323        $this->assertEquals( 'inherit', get_post( $post_id )->post_status );
    324324    }
     
    339339        $this->assertNotIXRError( $result );
    340340
    341         // Make sure that the post status is still inherit
     341        // Make sure that the post status is still inherit.
    342342        $this->assertEquals( 'draft', get_post( $post_id )->post_status );
    343343    }
     
    405405     */
    406406    function test_add_enclosure_if_new() {
    407         // Sample enclosure data
     407        // Sample enclosure data.
    408408        $enclosure = array(
    409409            'url'    => 'http://example.com/sound.mp3',
     
    412412        );
    413413
    414         // Second sample enclosure data array
     414        // Second sample enclosure data array.
    415415        $new_enclosure = array(
    416416            'url'    => 'http://example.com/sound2.mp3',
     
    419419        );
    420420
    421         // Create a test user
    422         $editor_id = $this->make_user_by_role( 'editor' );
    423 
    424         // Add a dummy post
     421        // Create a test user.
     422        $editor_id = $this->make_user_by_role( 'editor' );
     423
     424        // Add a dummy post.
    425425        $post_id = self::factory()->post->create(
    426426            array(
     
    432432        );
    433433
    434         // Add the enclosure as it is added in "do_enclose()"
     434        // Add the enclosure as it is added in "do_enclose()".
    435435        $enclosure_string = "{$enclosure['url']}\n{$enclosure['length']}\n{$enclosure['type']}\n";
    436436        add_post_meta( $post_id, 'enclosure', $enclosure_string );
    437437
    438         // Verify that the correct data is there
     438        // Verify that the correct data is there.
    439439        $this->assertEquals( $enclosure_string, get_post_meta( $post_id, 'enclosure', true ) );
    440440
    441         // Attempt to add the enclosure a second time
     441        // Attempt to add the enclosure a second time.
    442442        $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $enclosure );
    443443
    444         // Verify that there is only a single value in the array and that a duplicate is not present
     444        // Verify that there is only a single value in the array and that a duplicate is not present.
    445445        $this->assertEquals( 1, count( get_post_meta( $post_id, 'enclosure' ) ) );
    446446
    447         // For good measure, check that the expected value is in the array
     447        // For good measure, check that the expected value is in the array.
    448448        $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    449449
    450         // Attempt to add a brand new enclosure via XML-RPC
     450        // Attempt to add a brand new enclosure via XML-RPC.
    451451        $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $new_enclosure );
    452452
    453         // Having added the new enclosure, 2 values are expected in the array
     453        // Having added the new enclosure, 2 values are expected in the array.
    454454        $this->assertEquals( 2, count( get_post_meta( $post_id, 'enclosure' ) ) );
    455455
    456         // Check that the new enclosure is in the enclosure meta
     456        // Check that the new enclosure is in the enclosure meta.
    457457        $new_enclosure_string = "{$new_enclosure['url']}\n{$new_enclosure['length']}\n{$new_enclosure['type']}\n";
    458458        $this->assertTrue( in_array( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    459459
    460         // Check that the old enclosure is in the enclosure meta
     460        // Check that the old enclosure is in the enclosure meta.
    461461        $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    462462    }
Note: See TracChangeset for help on using the changeset viewer.