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/rest-api/rest-posts-controller.php

    r47080 r47122  
    6262        }
    6363
    64         // Only support 'post' and 'gallery'
     64        // Only support 'post' and 'gallery'.
    6565        self::$supported_formats = get_theme_support( 'post-formats' );
    6666        add_theme_support( 'post-formats', array( 'post', 'gallery' ) );
     
    151151
    152152    public function test_context_param() {
    153         // Collection
     153        // Collection.
    154154        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' );
    155155        $response = rest_get_server()->dispatch( $request );
     
    157157        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    158158        $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    159         // Single
     159        // Single.
    160160        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id );
    161161        $response = rest_get_server()->dispatch( $request );
     
    14551455     */
    14561456    public function test_get_items_invalid_max_pages() {
    1457         // Out of bounds
     1457        // Out of bounds.
    14581458        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
    14591459        $request->set_param( 'page', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
     
    20512051        add_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) );
    20522052
    2053         // reregister the route as we now have a template available.
     2053        // Re-register the route as we now have a template available.
    20542054        $GLOBALS['wp_rest_server']->override_by_default = true;
    20552055        $controller                                     = new WP_REST_Posts_Controller( 'post' );
     
    21532153        $params  = $this->set_post_data(
    21542154            array(
    2155                 // This results in a special `post_date_gmt` value of
    2156                 // '0000-00-00 00:00:00'. See #38883.
     2155                // This results in a special `post_date_gmt` value
     2156                // of '0000-00-00 00:00:00'. See #38883.
    21572157                'status' => 'pending',
    21582158            )
     
    22532253        $this->assertEquals( 'draft', $data['status'] );
    22542254        $this->assertEquals( 'draft', $new_post->post_status );
    2255         // Confirm dates are shimmed for gmt_offset
     2255        // Confirm dates are shimmed for gmt_offset.
    22562256        $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) );
    22572257        $post_date_gmt     = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) );
     
    27762776        $request->set_param( 'author', $post->post_author );
    27772777
    2778         // Run twice to make sure that the update still succeeds even if no DB
    2779         // rows are updated.
     2778        // Run twice to make sure that the update still succeeds
     2779        // even if no DB rows are updated.
    27802780        $response = rest_get_server()->dispatch( $request );
    27812781        $this->check_update_post_response( $response );
     
    32253225        $this->assertEquals( true, is_sticky( $post->ID ) );
    32263226
    3227         // Updating another field shouldn't change sticky status
     3227        // Updating another field shouldn't change sticky status.
    32283228        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
    32293229        $params  = $this->set_post_data(
     
    35653565
    35663566    public function verify_post_roundtrip( $input = array(), $expected_output = array() ) {
    3567         // Create the post
     3567        // Create the post.
    35683568        $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
    35693569        foreach ( $input as $name => $value ) {
     
    35743574        $actual_output = $response->get_data();
    35753575
    3576         // Compare expected API output to actual API output
     3576        // Compare expected API output to actual API output.
    35773577        $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] );
    35783578        $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
     
    35823582        $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
    35833583
    3584         // Compare expected API output to WP internal values
     3584        // Compare expected API output to WP internal values.
    35853585        $post = get_post( $actual_output['id'] );
    35863586        $this->assertEquals( $expected_output['title']['raw'], $post->post_title );
     
    35883588        $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt );
    35893589
    3590         // Update the post
     3590        // Update the post.
    35913591        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $actual_output['id'] ) );
    35923592        foreach ( $input as $name => $value ) {
     
    35973597        $actual_output = $response->get_data();
    35983598
    3599         // Compare expected API output to actual API output
     3599        // Compare expected API output to actual API output.
    36003600        $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] );
    36013601        $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
     
    36053605        $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
    36063606
    3607         // Compare expected API output to WP internal values
     3607        // Compare expected API output to WP internal values.
    36083608        $post = get_post( $actual_output['id'] );
    36093609        $this->assertEquals( $expected_output['title']['raw'], $post->post_title );
     
    39283928        register_taxonomy( 'status', 'post', array( 'show_in_rest' => true ) );
    39293929
    3930         // Re-initialize the controller
     3930        // Re-initialize the controller.
    39313931        $controller = new WP_REST_Posts_Controller( 'post' );
    39323932        $controller->register_routes();
     
    45394539        $response = rest_do_request( $request );
    45404540        $links    = $response->get_links();
    4541         // Authors can't ever unfiltered html
     4541        // Authors can't ever unfiltered html.
    45424542        $this->assertArrayNotHasKey( 'https://api.w.org/action-unfiltered-html', $links );
    45434543    }
Note: See TracChangeset for help on using the changeset viewer.