- Timestamp:
- 11/02/2016 03:36:40 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r39055 r39084 17 17 protected static $contributor_id; 18 18 19 protected static $supported_formats; 20 19 21 public static function wpSetUpBeforeClass( $factory ) { 20 22 self::$post_id = $factory->post->create(); … … 29 31 'role' => 'contributor', 30 32 ) ); 33 34 // Only support 'post' and 'gallery' 35 self::$supported_formats = get_theme_support( 'post-formats' ); 36 add_theme_support( 'post-formats', array( 'post', 'gallery' ) ); 31 37 } 32 38 33 39 public static function wpTearDownAfterClass() { 40 // Restore theme support for formats. 41 if ( self::$supported_formats ) { 42 add_theme_support( 'post-formats', self::$supported_formats ); 43 } else { 44 remove_theme_support( 'post-formats' ); 45 } 46 34 47 wp_delete_post( self::$post_id, true ); 35 48 … … 1079 1092 } 1080 1093 1094 /** 1095 * Test with a valid format, but one unsupported by the theme. 1096 * 1097 * https://core.trac.wordpress.org/ticket/38610 1098 */ 1099 public function test_create_post_with_unsupported_format() { 1100 wp_set_current_user( self::$editor_id ); 1101 1102 $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); 1103 $params = $this->set_post_data( array( 1104 'format' => 'link', 1105 ) ); 1106 $request->set_body_params( $params ); 1107 $response = $this->server->dispatch( $request ); 1108 1109 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1110 } 1111 1081 1112 public function test_create_update_post_with_featured_media() { 1082 1113 … … 1491 1522 $params = $this->set_post_data( array( 1492 1523 'format' => 'testformat', 1524 ) ); 1525 $request->set_body_params( $params ); 1526 $response = $this->server->dispatch( $request ); 1527 1528 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1529 } 1530 1531 /** 1532 * Test with a valid format, but one unsupported by the theme. 1533 * 1534 * https://core.trac.wordpress.org/ticket/38610 1535 */ 1536 public function test_update_post_with_unsupported_format() { 1537 wp_set_current_user( self::$editor_id ); 1538 1539 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 1540 $params = $this->set_post_data( array( 1541 'format' => 'link', 1493 1542 ) ); 1494 1543 $request->set_body_params( $params );
Note: See TracChangeset
for help on using the changeset viewer.