Changeset 40137
- Timestamp:
- 02/27/2017 08:02:43 PM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
- Property svn:mergeinfo changed
/trunk merged: 40120-40121
- Property svn:mergeinfo changed
-
branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r40136 r40137 1984 1984 1985 1985 case 'post-formats': 1986 $supports_formats = get_theme_support( 'post-formats' ); 1987 1988 // Force to an array. Supports formats can return true even if empty in some cases. 1989 $supports_formats = is_array( $supports_formats ) ? array_values( $supports_formats[0] ) : array(); 1990 1991 $supported_formats = array_merge( array( 'standard' ), $supports_formats ); 1986 // Get the native post formats and remove the array keys. 1987 $formats = array_values( get_post_format_slugs() ); 1992 1988 1993 1989 $schema['properties']['format'] = array( 1994 1990 'description' => __( 'The format for the object.' ), 1995 1991 'type' => 'string', 1996 'enum' => $ supported_formats,1992 'enum' => $formats, 1997 1993 'context' => array( 'view', 'edit' ), 1998 1994 ); -
branches/4.7/tests/phpunit/tests/rest-api/rest-posts-controller.php
r40136 r40137 991 991 } 992 992 993 public function test_get_items_no_supported_post_formats() { 994 // This causes get_theme_support( 'post-formats' ) to return `true` (not an array) 995 add_theme_support( 'post-formats' ); 996 993 public function test_get_items_all_post_formats() { 997 994 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); 998 995 $response = $this->server->dispatch( $request ); 999 996 $data = $response->get_data(); 1000 997 1001 // Set the expected state back for the rest of the tests. 1002 global $_wp_theme_features; 1003 unset( $_wp_theme_features['post-formats'] ); 1004 add_theme_support( 'post-formats', array( 'post', 'gallery' ) ); 1005 1006 $formats = array( 'standard' ); 998 $formats = array_values( get_post_format_slugs() ); 1007 999 1008 1000 $this->assertEquals( $formats, $data['schema']['properties']['format']['enum'] ); … … 1652 1644 $request->set_body_params( $params ); 1653 1645 $response = $this->server->dispatch( $request ); 1654 1655 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1646 $this->assertEquals( 201, $response->get_status() ); 1647 1648 $data = $response->get_data(); 1649 $this->assertEquals( 'link', $data['format'] ); 1656 1650 } 1657 1651 … … 2150 2144 $request->set_body_params( $params ); 2151 2145 $response = $this->server->dispatch( $request ); 2152 2153 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 2146 $this->assertEquals( 200, $response->get_status() ); 2147 2148 $data = $response->get_data(); 2149 $this->assertEquals( 'link', $data['format'] ); 2154 2150 } 2155 2151 -
branches/4.7/tests/qunit/fixtures/wp-api-generated.js
r40116 r40137 389 389 "required": false, 390 390 "enum": [ 391 "standard" 391 "standard", 392 "aside", 393 "chat", 394 "gallery", 395 "link", 396 "image", 397 "quote", 398 "status", 399 "video", 400 "audio" 392 401 ], 393 402 "description": "The format for the object.", … … 563 572 "required": false, 564 573 "enum": [ 565 "standard" 574 "standard", 575 "aside", 576 "chat", 577 "gallery", 578 "link", 579 "image", 580 "quote", 581 "status", 582 "video", 583 "audio" 566 584 ], 567 585 "description": "The format for the object.",
Note: See TracChangeset
for help on using the changeset viewer.