- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r47080 r47122 62 62 } 63 63 64 // Only support 'post' and 'gallery' 64 // Only support 'post' and 'gallery'. 65 65 self::$supported_formats = get_theme_support( 'post-formats' ); 66 66 add_theme_support( 'post-formats', array( 'post', 'gallery' ) ); … … 151 151 152 152 public function test_context_param() { 153 // Collection 153 // Collection. 154 154 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); 155 155 $response = rest_get_server()->dispatch( $request ); … … 157 157 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 158 158 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 159 // Single 159 // Single. 160 160 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id ); 161 161 $response = rest_get_server()->dispatch( $request ); … … 1455 1455 */ 1456 1456 public function test_get_items_invalid_max_pages() { 1457 // Out of bounds 1457 // Out of bounds. 1458 1458 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 1459 1459 $request->set_param( 'page', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); … … 2051 2051 add_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) ); 2052 2052 2053 // reregister the route as we now have a template available.2053 // Re-register the route as we now have a template available. 2054 2054 $GLOBALS['wp_rest_server']->override_by_default = true; 2055 2055 $controller = new WP_REST_Posts_Controller( 'post' ); … … 2153 2153 $params = $this->set_post_data( 2154 2154 array( 2155 // This results in a special `post_date_gmt` value of2156 // '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. 2157 2157 'status' => 'pending', 2158 2158 ) … … 2253 2253 $this->assertEquals( 'draft', $data['status'] ); 2254 2254 $this->assertEquals( 'draft', $new_post->post_status ); 2255 // Confirm dates are shimmed for gmt_offset 2255 // Confirm dates are shimmed for gmt_offset. 2256 2256 $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) ); 2257 2257 $post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) ); … … 2776 2776 $request->set_param( 'author', $post->post_author ); 2777 2777 2778 // Run twice to make sure that the update still succeeds even if no DB2779 // rows are updated.2778 // Run twice to make sure that the update still succeeds 2779 // even if no DB rows are updated. 2780 2780 $response = rest_get_server()->dispatch( $request ); 2781 2781 $this->check_update_post_response( $response ); … … 3225 3225 $this->assertEquals( true, is_sticky( $post->ID ) ); 3226 3226 3227 // Updating another field shouldn't change sticky status 3227 // Updating another field shouldn't change sticky status. 3228 3228 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 3229 3229 $params = $this->set_post_data( … … 3565 3565 3566 3566 public function verify_post_roundtrip( $input = array(), $expected_output = array() ) { 3567 // Create the post 3567 // Create the post. 3568 3568 $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); 3569 3569 foreach ( $input as $name => $value ) { … … 3574 3574 $actual_output = $response->get_data(); 3575 3575 3576 // Compare expected API output to actual API output 3576 // Compare expected API output to actual API output. 3577 3577 $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); 3578 3578 $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); … … 3582 3582 $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); 3583 3583 3584 // Compare expected API output to WP internal values 3584 // Compare expected API output to WP internal values. 3585 3585 $post = get_post( $actual_output['id'] ); 3586 3586 $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); … … 3588 3588 $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt ); 3589 3589 3590 // Update the post 3590 // Update the post. 3591 3591 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $actual_output['id'] ) ); 3592 3592 foreach ( $input as $name => $value ) { … … 3597 3597 $actual_output = $response->get_data(); 3598 3598 3599 // Compare expected API output to actual API output 3599 // Compare expected API output to actual API output. 3600 3600 $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); 3601 3601 $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); … … 3605 3605 $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); 3606 3606 3607 // Compare expected API output to WP internal values 3607 // Compare expected API output to WP internal values. 3608 3608 $post = get_post( $actual_output['id'] ); 3609 3609 $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); … … 3928 3928 register_taxonomy( 'status', 'post', array( 'show_in_rest' => true ) ); 3929 3929 3930 // Re-initialize the controller 3930 // Re-initialize the controller. 3931 3931 $controller = new WP_REST_Posts_Controller( 'post' ); 3932 3932 $controller->register_routes(); … … 4539 4539 $response = rest_do_request( $request ); 4540 4540 $links = $response->get_links(); 4541 // Authors can't ever unfiltered html 4541 // Authors can't ever unfiltered html. 4542 4542 $this->assertArrayNotHasKey( 'https://api.w.org/action-unfiltered-html', $links ); 4543 4543 }
Note: See TracChangeset
for help on using the changeset viewer.