Ticket #20396: 20396_unittests.patch
File 20396_unittests.patch, 15.5 KB (added by , 12 years ago) |
---|
-
wp-testcase/test-xmlrpc-api/test_mw_editPost.php
84 84 $this->assertEquals( $contributor_id, $out->post_author ); 85 85 } 86 86 87 function test_ featured_image() {87 function test_post_thumbnail() { 88 88 add_theme_support( 'post-thumbnails' ); 89 89 90 90 $author_id = get_user_by( 'login', 'author' )->ID; 91 $post = array( 'post_title' => ' Featured ImageTest', 'post_author' => $author_id );91 $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id ); 92 92 $post_id = wp_insert_post( $post ); 93 93 94 94 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); … … 100 100 $this->assertTrue( empty( $upload['error'] ) ); 101 101 102 102 $attachment = array( 103 'post_title' => ' Featured Image',103 'post_title' => 'Post Thumbnail', 104 104 'post_type' => 'attachment', 105 105 'post_mime_type' => 'image/jpeg', 106 106 'guid' => $upload['url'] 107 107 ); 108 108 $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); 109 109 110 // add featured imageto post that does not have one111 $post2 = array( 'wp_ featured_image' => $attachment_id );110 // add post thumbnail to post that does not have one 111 $post2 = array( 'wp_post_thumbnail' => $attachment_id ); 112 112 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) ); 113 113 $this->assertNotInstanceOf( 'IXR_Error', $result ); 114 114 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 115 115 116 // edit the post without supplying a featured_imageand check that it didn't change116 // edit the post without supplying a post thumbnail and check that it didn't change 117 117 $post3 = array( 'post_content' => 'Updated post' ); 118 118 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) ); 119 119 $this->assertNotInstanceOf( 'IXR_Error', $result ); 120 120 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 121 121 122 122 // create another attachment 123 $attachment2 = array_merge( $attachment, array( 'title' => ' Featured Image2' ) );123 $attachment2 = array_merge( $attachment, array( 'title' => 'Post Thumbnail 2' ) ); 124 124 $attachment2_id = wp_insert_attachment( $attachment2, $upload['file'], $post_id ); 125 125 126 // change the post's featured_image127 $post4 = array( 'wp_ featured_image' => $attachment2_id );126 // change the post's thumbnail 127 $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); 128 128 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) ); 129 129 $this->assertNotInstanceOf( 'IXR_Error', $result ); 130 130 $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 131 131 132 // unset the post's featured_image133 $post5 = array( 'wp_ featured_image' => '' );132 // unset the post's post thumbnail 133 $post5 = array( 'wp_post_thumbnail' => '' ); 134 134 $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) ); 135 135 $this->assertNotInstanceOf( 'IXR_Error', $result ); 136 136 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); -
wp-testcase/test-xmlrpc-api/test_mw_getPost.php
87 87 $this->assertEquals( $this->post_data['post_excerpt'], $result['mt_excerpt'] ); 88 88 $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id ); 89 89 90 $this->assertEquals( '', $result['wp_ featured_image'] );91 $this->assertEquals( '', $result['wp_ featured_image_url'] );90 $this->assertEquals( '', $result['wp_post_thumbnail'] ); 91 $this->assertEquals( '', $result['wp_post_thumbnail_url'] ); 92 92 93 93 remove_theme_support( 'post-thumbnails' ); 94 94 } 95 95 96 function test_ featured_image() {96 function test_post_thumbnail() { 97 97 add_theme_support( 'post-thumbnails' ); 98 98 99 99 // create attachment … … 103 103 $this->assertTrue( empty( $upload['error'] ) ); 104 104 105 105 $attachment = array( 106 'post_title' => ' Featured Image',106 'post_title' => 'Post Thumbnail', 107 107 'post_type' => 'attachment', 108 108 'post_mime_type' => 'image/jpeg', 109 109 'guid' => $upload['url'] … … 116 116 $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'author', 'author' ) ); 117 117 $this->assertNotInstanceOf( 'IXR_Error', $result ); 118 118 119 $this->assertInternalType( 'string', $result['wp_ featured_image'] );120 $this->assertStringMatchesFormat( '%d', $result['wp_ featured_image'] );121 $this->assertEquals( $attachment_id, $result['wp_ featured_image'] );119 $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); 120 $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 121 $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); 122 122 123 $this->assertInternalType( 'string', $result['wp_ featured_image_url'] );124 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_ featured_image_url'] );123 $this->assertInternalType( 'string', $result['wp_post_thumbnail_url'] ); 124 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_post_thumbnail_url'] ); 125 125 126 126 delete_post_thumbnail( $this->post_id ); 127 127 remove_theme_support( 'post-thumbnails' ); -
wp-testcase/test-xmlrpc-api/test_mw_getRecentPosts.php
83 83 $this->assertEquals( $post->post_excerpt, $result['mt_excerpt'] ); 84 84 $this->assertEquals( url_to_postid( $result['link'] ), $post->ID ); 85 85 86 $this->assertEquals( '', $result['wp_ featured_image'] );87 $this->assertEquals( '', $result['wp_ featured_image_url'] );86 $this->assertEquals( '', $result['wp_post_thumbnail'] ); 87 $this->assertEquals( '', $result['wp_post_thumbnail_url'] ); 88 88 } 89 89 90 90 remove_theme_support( 'post-thumbnails' ); 91 91 } 92 92 93 function test_ featured_image() {93 function test_post_thumbnail() { 94 94 add_theme_support( 'post-thumbnails' ); 95 95 96 96 // create attachment … … 100 100 $this->assertTrue( empty( $upload['error'] ) ); 101 101 102 102 $attachment = array( 103 'post_title' => ' Featured Image',103 'post_title' => 'Post Thumbnail', 104 104 'post_type' => 'attachment', 105 105 'post_mime_type' => 'image/jpeg', 106 106 'guid' => $upload['url'] … … 112 112 $this->assertNotInstanceOf( 'IXR_Error', $results ); 113 113 114 114 foreach( $results as $result ) { 115 $this->assertInternalType( 'string', $result['wp_ featured_image'] );116 $this->assertStringMatchesFormat( '%d', $result['wp_ featured_image'] );117 $this->assertInternalType( 'string', $result['wp_ featured_image_url'] );115 $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); 116 $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 117 $this->assertInternalType( 'string', $result['wp_post_thumbnail_url'] ); 118 118 119 if( ! empty( $result['wp_ featured_image'] ) || $result['postid'] == $this->post_id ) {119 if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == $this->post_id ) { 120 120 $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); 121 121 122 $this->assertEquals( $attachment_id, $result['wp_ featured_image'] );123 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_ featured_image_url'] );122 $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); 123 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_post_thumbnail_url'] ); 124 124 } 125 125 } 126 126 -
wp-testcase/test-xmlrpc-api/test_mw_newPost.php
83 83 $this->assertEquals( 'Test', $out->post_title ); 84 84 } 85 85 86 function test_ featured_image() {86 function test_post_thumbnail() { 87 87 add_theme_support( 'post-thumbnails' ); 88 88 89 89 // create attachment … … 93 93 $this->assertTrue( empty( $upload['error'] ) ); 94 94 95 95 $attachment = array( 96 'post_title' => ' Featured Image',96 'post_title' => 'Post Thumbnail', 97 97 'post_type' => 'attachment', 98 98 'post_mime_type' => 'image/jpeg', 99 99 'guid' => $upload['url'] 100 100 ); 101 101 $attachment_id = wp_insert_attachment( $attachment, $upload['file'] ); 102 102 103 $post = array( 'title' => ' Featured Image Test', 'wp_featured_image' => $attachment_id );103 $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); 104 104 $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); 105 105 $this->assertNotInstanceOf( 'IXR_Error', $result ); 106 106 $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); -
wp-testcase/test-xmlrpc-api/test_wp_editPost.php
84 84 $this->assertEquals( $contributor_id, $out->post_author ); 85 85 } 86 86 87 function test_ featured_image() {87 function test_post_thumbnail() { 88 88 add_theme_support( 'post-thumbnails' ); 89 89 90 90 $author_id = get_user_by( 'login', 'author' )->ID; 91 $post = array( 'post_title' => ' Featured ImageTest', 'post_author' => $author_id );91 $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id ); 92 92 $post_id = wp_insert_post( $post ); 93 93 94 94 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); … … 100 100 $this->assertTrue( empty( $upload['error'] ) ); 101 101 102 102 $attachment = array( 103 'post_title' => ' Featured Image',103 'post_title' => 'Post Thumbnail', 104 104 'post_type' => 'attachment', 105 105 'post_mime_type' => 'image/jpeg', 106 106 'guid' => $upload['url'] … … 108 108 $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); 109 109 110 110 // add featured image to post that does not have one 111 $post2 = array( ' featured_image' => $attachment_id );111 $post2 = array( 'post_thumbnail' => $attachment_id ); 112 112 $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post2 ) ); 113 113 $this->assertNotInstanceOf( 'IXR_Error', $result ); 114 114 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); … … 120 120 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 121 121 122 122 // create another attachment 123 $attachment2 = array_merge( $attachment, array( 'post_title' => ' Featured Image2' ) );123 $attachment2 = array_merge( $attachment, array( 'post_title' => 'Post Thumbnail 2' ) ); 124 124 $attachment2_id = wp_insert_attachment( $attachment2, $upload['file'], $post_id ); 125 125 126 126 // change the post's featured_image 127 $post4 = array( ' featured_image' => $attachment2_id );127 $post4 = array( 'post_thumbnail' => $attachment2_id ); 128 128 $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post4 ) ); 129 129 $this->assertNotInstanceOf( 'IXR_Error', $result ); 130 130 $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 131 131 132 132 // unset the post's featured_image 133 $post5 = array( ' featured_image' => '' );133 $post5 = array( 'post_thumbnail' => '' ); 134 134 $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post5 ) ); 135 135 $this->assertNotInstanceOf( 'IXR_Error', $result ); 136 136 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); -
wp-testcase/test-xmlrpc-api/test_wp_getOptions.php
57 57 $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); 58 58 $this->assertTrue( $result['stylesheet']['readonly'] ); 59 59 60 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result[' featured_image']['value'] );61 $this->assertTrue( $result[' featured_image']['readonly'] );60 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); 61 $this->assertTrue( $result['post_thumbnail']['readonly'] ); 62 62 63 63 // Updatable options 64 64 $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); … … 140 140 $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); 141 141 $this->assertTrue( $result['stylesheet']['readonly'] ); 142 142 143 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result[' featured_image']['value'] );144 $this->assertTrue( $result[' featured_image']['readonly'] );143 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); 144 $this->assertTrue( $result['post_thumbnail']['readonly'] ); 145 145 146 146 // Updatable options 147 147 $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); -
wp-testcase/test-xmlrpc-api/test_wp_getPost.php
59 59 $this->assertInternalType( 'string', $result['ping_status'] ); 60 60 $this->assertInternalType( 'bool', $result['sticky'] ); 61 61 $this->assertInternalType( 'string', $result['post_format'] ); 62 $this->assertInternalType( 'string', $result[' featured_image'] );62 $this->assertInternalType( 'string', $result['post_thumbnail'] ); 63 63 64 64 // Check expected values 65 65 $this->assertStringMatchesFormat( '%d', $result['post_id'] ); … … 70 70 $this->assertEquals( $this->post_data['post_excerpt'], $result['post_excerpt'] ); 71 71 $this->assertEquals( $this->post_data['post_content'], $result['post_content'] ); 72 72 $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id ); 73 $this->assertEquals( '', $result[' featured_image'] );73 $this->assertEquals( '', $result['post_thumbnail'] ); 74 74 75 75 remove_theme_support( 'post-thumbnails' ); 76 76 } -
wp-testcase/test-xmlrpc-api/test_wp_newPost.php
82 82 $this->assertEquals( 'Test', $out->post_title ); 83 83 } 84 84 85 function test_ featured_image() {85 function test_post_thumbnail() { 86 86 add_theme_support( 'post-thumbnails' ); 87 87 88 88 // create attachment … … 92 92 $this->assertTrue( empty( $upload['error'] ) ); 93 93 94 94 $attachment = array( 95 'post_title' => ' Featured Image',95 'post_title' => 'Post Thumbnail', 96 96 'post_type' => 'attachment', 97 97 'post_mime_type' => 'image/jpeg', 98 98 'guid' => $upload['url'] 99 99 ); 100 100 $attachment_id = wp_insert_attachment( $attachment, $upload['file'] ); 101 101 102 $post = array( 'post_title' => ' Featured Image Test', 'featured_image' => $attachment_id );102 $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); 103 103 $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); 104 104 $this->assertNotInstanceOf( 'IXR_Error', $result ); 105 105 $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );